I have a MySQL database that I access using PHP. Basically, I want to have a "switch" in the MySQL database which turns on or off based on a simple SELECT query (e.g. a value in a field in a table). Depending on the value returned (e.g. ON or OFF in a value somewhere in the database), there needs to be some dynamic HTML shown (an HTML form created from a different PHP/MySQL query). If the SELECT gets an "ON" value, then it will show the HTML form including dynamically created values from PHP. If it's "OFF", then the HTML form disappears, and the HTML page is blank. This "switch" needs be checked every two seconds (so the form appears or disappears quickly), but when the switch is "ON", I don't want the actual HTML form (from the second PHP/MySQL query) refreshing every two seconds.
It's like I need two PHP/MySQL queries working together - one every two seconds checking the switch, and the other running a different query which generates the HTML form itself that is shown when the switch is on.
This is what should happen:
1. When the HTML page first loads, the switch should be checked. If the switch is ON, run the PHP SELECT query once that selects some other data from another table in the database and spits out some HTML containing this dynamic data.
2. Keep checking the switch every two seconds, but do not refresh the dynamic HTML form while the switch is still on. I don't want the form flashing or refreshing while someone is trying to use it. Hold the form steady, but keep checking the switch.
3. Continue checking the switch every two seconds.
4. When the switch is finally OFF, make the HTML form disappear so the HTML page goes blank. It is fine if the person hasn't filled in the form - it should disappear anyway.
If you could give me files that show me how to do this using AJAX, I'd be most appreciative.
If you have more questions, just ask.
35 freelancers are bidding on average $28 for this job
I have more than 9 years of experience in web/mobile development. I have completed many mobile/web applications. We can discuss in detail further. Thanks Stay tuned, I'm still working on this proposal.