Guest_imported
New member
- Jan 1, 1970
- 0
Basically this query is looping over all items in basket for an order. But instead of returning 1st item, 2nd item, 3rd item in basket like it is suppost to, it will only bring back item 1 for as many times as there are items in the basket. I need to tell the db to point to the next row in the loop to fix the problem, but I not sure how to do this. Any help or suggestions would really cure my headache, thanks.
$query = "select * from order_items where
orderid = '$orderid'";
$result = mysql_query($query);
$num_results = mysql_num_rows($result);
for ($j=0; $j < $num_results; $j++){
$query = "select * from order_items where
orderid = '$orderid'";
$result = mysql_query($query);
$row = mysql_fetch_array($result);
echo stripslashes($row["itemNum"]);
echo stripslashes($row["item"]);
echo stripslashes($row["quantity"]);
}
The loop does work the correct amount of times but only returns the first item in basket. I need it to return each item in basket. How do you tell mysql to point to the next db row? Any suggestions would really be appreciated.
$query = "select * from order_items where
orderid = '$orderid'";
$result = mysql_query($query);
$num_results = mysql_num_rows($result);
for ($j=0; $j < $num_results; $j++){
$query = "select * from order_items where
orderid = '$orderid'";
$result = mysql_query($query);
$row = mysql_fetch_array($result);
echo stripslashes($row["itemNum"]);
echo stripslashes($row["item"]);
echo stripslashes($row["quantity"]);
}
The loop does work the correct amount of times but only returns the first item in basket. I need it to return each item in basket. How do you tell mysql to point to the next db row? Any suggestions would really be appreciated.