Jump to content
  • Advertisement
Sign in to follow this  
stormwarestudios

[web] PHP + MySQL + JavaScript

This topic is 3855 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello all, I'm writing a web-app here at work which generates graphs based on selections of data submitted by the user. Everything is peachy right now... except that a lot of the values I have configured are hard-coded into the PHP/HTML script I have written. Ideally what I'd like to do is have the selection boxes (combo boxes) on the page generated dynamically. For example: [Planet] [Continent] [Country] [City] At page load, only the contents of Planet are populated. When the user selects a Planet, the options for Continent are populated. Likewise, when Continent is selected, options for Country are populated, and so on. This is all easy peasy javascript. The difficult part is that the data populated into the combo boxes are unknown at runtime, and must be loaded from tables in a MySQL database using PHP. I have been searching on the web all day today trying to figure out how to link the two (i.e. putting data tables into multi-dynamic combo boxes). The best solution I can come up with is: - At page load time, read through the MySQL data I have, and generate a 4-dimensional array on-the-fly by echo()ing JS code, via PHP. - During the form's onChange() event generated by user mouse-clicks, empty the contents of certain combo boxes, and populate the data from the global JS array. Am I on the right track?

Share this post


Link to post
Share on other sites
Advertisement
That sounds like it should work, however, you might want to try to use AJAX to dynamically load the data when the user's clicks one of the buttons. This can be done easily by using a library such as scriptaculous (http://script.aculo.us/) or prototype (http://www.prototypejs.org/). Basically you will just load a php file each time the user clicks on a button by calling Ajax.request.

Share this post


Link to post
Share on other sites
Depending on how much data you have for all possible fields it may be best to load it dynamically as TOmcAT23 suggests. If you dump all of your data for everything into the page at load time, it could increase the load time enough that it ruins the user's experience.

If it's not that much data, go for it. Otherwise, sprinkle a little AJAX in there and make sure you let the user know more data is being loaded when they make a change ;)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!