Newbie question - creating arrays from multiple rows
Posted: Thu Sep 28, 2006 2:46 pm
Hi. Can anyone help?
I've got the following table:
product_id dimensions weight
45 35x24x13 3.95
45 24x12x6 2.76
I need to retrieve all the different dimensions-weight pairs for the same product_id.
My code is as follows:
$size_weight_query = mysql_query("select dimensions, weight from " . TABLE_SIZE_WEIGHT_PAIRS . " where product_id = 45");
$size_weight_query_array = mysql_fetch_array($size_weight_query);
with this set up, $size_weight_query_array['dimensions'] and $size_weight_query_array['weight'] only contain one
element each - the data from the first row only. I need each of these arrays to contain ALL the 'dimensions' and 'weight's
from every row which has the same product_id
I'd be really grateful for any help - the remainder of my hair is under serious threat.
Regards
Nick
I've got the following table:
product_id dimensions weight
45 35x24x13 3.95
45 24x12x6 2.76
I need to retrieve all the different dimensions-weight pairs for the same product_id.
My code is as follows:
$size_weight_query = mysql_query("select dimensions, weight from " . TABLE_SIZE_WEIGHT_PAIRS . " where product_id = 45");
$size_weight_query_array = mysql_fetch_array($size_weight_query);
with this set up, $size_weight_query_array['dimensions'] and $size_weight_query_array['weight'] only contain one
element each - the data from the first row only. I need each of these arrays to contain ALL the 'dimensions' and 'weight's
from every row which has the same product_id
I'd be really grateful for any help - the remainder of my hair is under serious threat.
Regards
Nick