Jump to content

PHP echo table dependent on drop down box's on same page


edd12345678

Recommended Posts

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

 

 

 

Link to comment
Share on other sites

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?

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.