edd12345678 Posted February 10, 2012 Share Posted February 10, 2012 Hi, I wonder if I somebody can help me I have three drop down lists which are populated from data thats stored in my sql database. I also have a table which is echoed from the database all on the same page. What i want to do is allow users to select values in the drop down lists which will then echo different results below in the table. Is this possible. So on page load it will show all of the info in the html table. Then when the user changes the drop downs and clicks submit it will change the query to something SELECT dropdown1 value FROM users where Dropdown2 = 1 AND Dropdown3 = 2 etc. Is this possible to display this information on the same page using the dropdown list or does it need to load a different page as the client side is trying to edit a server side script? If its possible please can someone give me an example. Thanks in advance Edd Quote Link to comment https://forums.phpfreaks.com/topic/256844-php-echo-table-dependent-on-drop-down-boxs-on-same-page/ Share on other sites More sharing options...
sunfighter Posted February 11, 2012 Share Posted February 11, 2012 A rule of thumb here is any time you need to access a database you have to go server side so the page reloads or you use ajax and the page just changes. using ajax you don't need a submit button for the dropdowns( actually that's because of javascript). Each one can fire the ajax using the onchange tag. So here's an example that means without the need to load a new page. Your table lists every person,all 300 million plus, by name, that lives in the US. The first DD(drop down) picks OHIO and the table changes to list only those that live in ohio. The second DD chooses Akron, the table again changes. The last DD picks THOMAS and now the table has the name of every body that lives in Akron, Oh with the first name of Thomas. So what do you want to do? Quote Link to comment https://forums.phpfreaks.com/topic/256844-php-echo-table-dependent-on-drop-down-boxs-on-same-page/#findComment-1317024 Share on other sites More sharing options...
edd12345678 Posted February 12, 2012 Author Share Posted February 12, 2012 Hi, Thankyou for your reply. I have now resolved the problem. I created a form to post the variables to another page. Then I saved them into a session variable and echoed them back on to the required page if that makes sense. Thanks anyway. Edd Quote Link to comment https://forums.phpfreaks.com/topic/256844-php-echo-table-dependent-on-drop-down-boxs-on-same-page/#findComment-1317366 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.