Link to home
Start Free TrialLog in
Avatar of burnedfaceless
burnedfaceless

asked on

Call php in file

Let's say I have a mostly html file with some php.

I have a form (all select values) and i want to call php when one of those is selected without going to an external file.

How do I do this? Function?
Avatar of Gary
Gary
Flag of Ireland image

PHP runs at the server - it doesn't exist in the browser.
If you want to run some php (for whatever reason) when a dropdown is changed then you either need to submit the page back to the server or use ajax to call a page on the server.
Avatar of burnedfaceless
burnedfaceless

ASKER

I'm having a problem where the following page

conutils.com/dist/rates

If you visit from a desktop it works. It's not supposed to do anything when you visit it from mobile, but it messes up the menu - if you could visit from mobile and look.

I've thought about messing around with the css but I figured the easiest thing to do would be echo html similar to our jquery example, without having to change the url of the user.

What would you recommend?
Even if it's not proper client server distribution my boss wants this part mobile so I need to get it done.
Confused.
You have two dropdowns marked desktop and mobile (don't see the point)

It's not supposed to do anything when you visit it from mobile
What is supposed to happen on mobile then?
Are we getting confused between the two questions?
It's mainly because the display will be different when I am finished.

It's not connected to jquery (consolidated.js) because the rendering error occurred when I displayed a water system. I isolated it to the select (form) itself by removing everything.
Basically I kept it simple and I know that the form is causing the css menu to screw up, so I have to either fix that in css, or find a way with php or ajax that will display systems.

I hope that I explained my problem.
The question isn't about menus ::still confused::
There may be a lot of background information you need to understand before you can craft this question in a way we can help with an answer.

HTTP Client / Server Protocols
https://www.experts-exchange.com/Web_Development/Web_Languages-Standards/A_11271-Understanding-Client-Server-Protocols-and-Web-Applications.html

The Basics of PHP
https://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_11769-And-by-the-way-I-am-new-to-PHP.html

Using jQuery (or any AJAX action, for that matter)
https://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Jquery/A_10712-The-Hello-World-Exercise-with-jQuery-and-PHP.html

Probably this last article is what you want to implement, but it will be easier for you if you understand the content of the first two articles.

Best of luck with the project, ~Ray
Thanks Ray. I'll read tomorrow.
Ray I wanted to make sure you were familiar with this thread before I start reading stuff that doesn't relate....

https://www.experts-exchange.com/questions/28306814/css-mobile-menu-expands.html?anchorAnswerId=39686204#a39686204
I'm assuming that you view this algorithm as the only possible solution...have php echo every detail. Unless you respond.
I read the other question and posted a comment there.  I don't think the articles listed here are "stuff that doesn't relate."  They are like arithmetic when the question is about finance -- fundamental things you must understand in order to communicate about the larger issues.  Take some time to read and understand, and experiment with the code examples.  You will have a much better understanding of what you're trying to do!  Then come back here and help me understand this:
... have php echo every detail
Please clarify?  I think the answer is probably, "yes," but I would like to have the dialog in more specific terms if possible.  Thanks, ~Ray
Well obviously that's the idea that someone who was on too much amphetamine would have (I'm not on that it's a joke).

My boss wants it done and having a php page that echoes the page with the menu would not distort the menu it just would take a long time.
This page works fine desktop.

It's the mobile version, which isn't tied into it anyways.

I will read what you put. But I know the form is causing the menu expansion - at the end of the day I have to get this shit done.
Actually don't answer that. Let me see if I can figure it out.
We understand that it's your responsibility, and we're trying to help, but it's also obvious that you're in over your head.  Example: Go to http://conutils.com/dist/rates/ and use view source.  Look at line 10 and 11.  Then look at line 211 and 212.  This just doesn't make any sense.  You may want one or the other, but not both of these tags.  The latest jQuery minified is available here:
http://code.jquery.com/jquery-latest.min.js

Next, look at http://conutils.com/dist/js/consolidated.js where it seems that the entire response set has been hardcoded into a JavaScript library in the form of lengthy HTML strings.  A better design would be an AJAX call to a PHP script that returned the HTML strings.  The PHP script could rely on a data base, and the table maintenance for the data base could be performed through simple HTML forms.  You would use this sort of design because the people who do rate setting are unlikely to be comfortable editing a JavaScript file.

Go back to the view source again and look at the select controls for "WaterSystem" and "WaterSystem2."  The option tags are exactly the same, strongly suggesting that this code fails the "don't repeat yourself" test.  This should be one select control, because there is no value added in the duplicated options.

It's this sort of thing that leads me to believe that the best way we can help you is to look back to the fundamentals and try to build up the application one piece at a time.  For example, you might want to have PHP generate all of the HTML document.  PHP can look at HTTP_USER_AGENT and make some intelligent determination about whether the browser is mobile or desktop.  PHP can use this information to tailor the generation of CSS and JavaScript, as well as the markup.
1. One thing at a time. Do we want the latest jquery? Would there be compatibility issues.

I'm a n00b when it comes to interaction between the web elements, but as someone said almost every programming concept was invented in the '70s. So I understand the thinking.

2. Would you provide examples on php generation of more of the page, either in Build Your Own Database Driven Web Site Using Php & MySQL?

Or on this page.

The jquery works fine on the desktop and I don't want to change what isn't broken but I'm interested in learning about the AJAX or php writing more of the page. I may make some major changes.

3. FWIW I am considering a minor or major change to computer science. Would a minor give me enough of a background to code a database?

One thing I learned in music is the first two classes (music theory) were the pertinent ones. The final two of the sequence just messed with your head.
And Ray I've debugged it, the issue is any form submission.

What you are suggesting won't fix the problem.

Trust me I've programmed in an academic setting with c++, pascal, and basic for robotics. I know how to isolate the problem.

edit: i'm interested in learning more about writing with php because I want to learn that.

Maybe it would fix the problem if it would rewrite the menu.

Let's go to some examples Ray this will be fun:
Look if nobody has any ideas I'll just echo the damn thing.
ASKER CERTIFIED SOLUTION
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks Ray I'm changing my minor.