so I'm working on a "product listing", and the idea is to have the name of the product and then a drop down list of colours derived from the database. The problem is I can only get the "colours" while loop to iterate the once, I get the first product name and the colours in the drop down menu the once but not subsequently, the help I'd like is, how can I change this code to make it do what I need, I've been trying for a week and I could really use some help.
$product_query = mysql_query('SELECT * FROM products WHERE id > 0');
$colour_query = mysql_query('SELECT * FROM product_colours WHERE id > 0');
while ($get_product_rows = mysql_fetch_assoc($product_query)){
echo $get_product_rows['name'];
echo "<br \>";
if ($get_product_rows['has_colour'] == '1'){
while ($get_colour_row = mysql_fetch_assoc($colour_query)){
// Drop down box population goes here.
}
}
}
If anyone can help I would appreciate it. From Grant M.
var_dump(mysql_fetch_assoc($color_query))and update your question with the output?productstoproduct_coloursmight be more efficient (depending on a lot of factors like database link latency, number of rows in each result set...)