Forum Moderators: coopster

Message Too Old, No Replies

Retrieve data from multiple tables via combo

Using combo to select the primary key on which to select data from 2 tables

         

Byron78

8:05 am on May 19, 2005 (gmt 0)



Hi all,

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

ergophobe

3:53 pm on May 19, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Welcome to WebmasterWorld 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.