PDA

View Full Version : Multiple Querries in a database


dw396
11-19-2009, 09:20 AM
Hi,
I'm working on my first dynamic database project (OOOOOOOO). I've never used php, mysql or anything else. (I'm even using div's and css layouts for the first time). I've got login's, updates, adding new info to tables, everything's going well untill the final step.


I'm trying to querry a database and break the results down table by table to give an answer.

I have 3 tables in the database.

The first one is the Category
Second Product
Third 'Supplier' details

So you start by choosing a category ( say Car, Bike or Lorry), then based on that result you choose a product (Red Car, Blue Car, Yellow Car etc). Then on that result you get a list of supplier.

The first two are easy. But the third question is harder I have say 5 'suppliers' and I've broken the table down so it carries all the info like this

a b c d e f
prod_id cat_id prod_name prod_descr dealer_a dealer_b etcetc
1 1 Red Car description 0 0
2 1 Blue Car description 1 0
3 1 Yellow Car description 1 0
4 2 Green Bike description 0 1

a-d are self explanitory

e,f - are the names of the 'suppliers'. If they have a 1 they 'have that car. A 0 means no. (with me so far?)

So the blue car is available from dealer_a but not dealer_b. Now I need to get dealer_a's contact details from the suppliers table.

That's where I'm completly stuck. Have I laid the table out wrong? what's the querry/variable. I can see it works, but I've no idea how.

Any ideas - I'm offering free beer to anyone that can come up with a working answer as this is driving me mad!!!!!!!! I just want to see it working.

edbr
11-20-2009, 01:40 AM
so you have ex. $row[''blue_car]
you need to select * from table 3 where prod_name= $row[''blue_car];
then you can echo out the dealers info
if i have got your table structure correct that is