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?
Query two tables on same page depending on ID
Moderator: General Moderators
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
to
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
change this line
Code: Select all
$query = "SELECT * FROM " . $product_array[$product_id] . " WHERE product_id = '$product_id'";Code: Select all
$query = "SELECT * FROM " . $product_array[$product_id] . " WHERE id = '$product_id'";Mark
have a look at this mysql join tutorial.