Forum Moderators: coopster
I am working on a small project to create a single web page which retrieves data from 3 tables.
The first table is retrieved by a combo box. It only contains the primary key of the table. I know how to get the data in the combo.
The second table contains other information, related to the primary key of table 1. I know how to retrieve all the data, but not how to retrieve only the data of the selected primary key.
I think I should work with a WHERE clause in the SELECT statement, but I have no idea how to get to the selected value.
The third table should work in a similar way, so when I have an answer for the second table, I can also use it for the third table.
Many thanks,
Byron
The first thing to know is that if you want one combo populated based on the selection you make in another one, you have two options
- use Javascript
- use a succession of pages.
In other words, once the page is displayed, PHP can't do anything unless you request another page.
Once you've sent your post data, then it's just
SELECT field1, field2 FROM table1 WHERE field2=$_POST['combo1'] ORDER BY field2
Something like that.