0
How to implement dynamic select boxes in php and mysql?
5 Answers
+ 1
Not enough informations...
Where does the data comes from ? JavaScript or Php ?
If the data comes from the first you can create the boxes with javascript with a for or for of and if its from a Php page you could create a template with php and inject the information within (once again with a for or foreach)
Might be of more help if you got information or a bit of code to share
+ 1
Are you the one implementing those lists in your HTML or are these in a SQL db ?
I would go with JavaScript for the interactivity : probably a addEventListener ('change', function() {} ); on the two first select boxes.
A nice option (my point of view) would be to block the list of college till one of the two first select list is checked.
Now this would only work if you already have the necessary informations on your page (in hard in the html or SQL pre implemented)
If not you could use a form, post the two selected choices and send back the colleges available (with php and SQL).
It actually depends of how you want it to look and if you care that the user need to reload the page.
If needed, I could help, I like those kind of stuff :P
You could also use AJAX which would be able to "combine" the two solutions (going through request without reloading the page) but I'm not comfortable with this language (yet) so cannot tell you more about it
+ 1
Yep so like I said I would either fetch all the available colleges and put those in different tables in Js (like a copycat of your database) and then with Js display the ones the user is looking for
Or only put 2 select on the web page and then fetch a list of colleges from the database to display it
One way is more user-interactive / friendly but heavier (Js) the other one is easier and lighter but the user would have to re-submit the form each time
0
I've implemented three select box of region college and departments. Whenever a user will select any region then, only college of that particular region should be selected. That's why i want my select boxes to be dynamic so that the option will change according to the selection of user
0
I have stored the data in database and I am fetching that data into option tag