Page 2 of 2

Posted: Mon Aug 18, 2003 11:42 am
by yinka
I get this error now.

Unknown column 'product_id' in 'where clause'

I was using that line of code because my main table is called "products."
That is where I am holding the the inormation for each product and setting the ID. Each table that I have in the array, I want to show up when the products table row comes up.

For example, I have product named "as." It is in the "products" table and it's ID is 1. When I go to that URL, I also want the table called "as" that holds all the information for that product. Does that make sense?

Posted: Mon Aug 18, 2003 11:58 am
by JayBird
have you actually got a column called product_id, according to that error message you haven't, and by looking at the other SQL statement you have constructed, the column you should be refering to is ID

change this line

Code: Select all

$query = "SELECT * FROM " . $product_array[$product_id] . " WHERE product_id = '$product_id'";
to

Code: Select all

$query = "SELECT * FROM " . $product_array[$product_id] . " WHERE id = '$product_id'";
The reason i ask about the line of code is becuase you set $query to equal the first SQL statement, then immeadiately overwrite it with another SQL statement!

Mark

Posted: Mon Aug 18, 2003 12:04 pm
by yinka
ARGG! I don't know what the heck I am doing! The comumn that I have in the "products" table is just ID.

Posted: Mon Aug 18, 2003 12:10 pm
by JayBird
well, the code i just gave you should have sorted out the last error then. Are you still getting errors?

Mark

Posted: Mon Aug 18, 2003 12:12 pm
by yinka
I get this now:

Unknown column 'id' in 'where clause'

But now, I don't see in the code how I would get an ID from the "products table first.

Posted: Mon Aug 18, 2003 12:32 pm
by patrikG
have a look at this mysql join tutorial.

Posted: Mon Aug 18, 2003 1:40 pm
by yinka
Yeah, I guess what I have to do it join the tables. I'll try to figure out how to do it. Thanks guys.