Wh does my output echo twice?
Posted: Thu Mar 09, 2006 5:27 am
Hi,
I've written this code to output the items in a user's shopping cart in basic format for now, andit works fine except that it echoes the output twice and I can't figure out why.
Can anyone see what's going wrong here? I'm baffled...
Thanks in advance,
Matt
I've written this code to output the items in a user's shopping cart in basic format for now, andit works fine except that it echoes the output twice and I can't figure out why.
Code: Select all
$oid=$_GET['order_id'];
$sql="SELECT items FROM orders WHERE order_ref='$oid'";
$result=mysql_query($sql);
$i=mysql_fetch_array($result);
foreach($i as $key => $value){
$items=explode(",",$value);
sort($items);
//For ech of the results returned by the above...
foreach($items as $value){
//...grab the details of each item in $value
$sql="SELECT * FROM catalogue WHERE prod_id='$value'";
$result=mysql_query($sql);
$num=mysql_num_rows($result);
//display the results
$i=0;
while ($i<$num){
$prodid=mysql_result($result,$i,"prod_id");
$prodname=mysql_result($result,$i,"prod_name");
$price=mysql_result($result,$i,"price");
//$short_desc=mysql_result($result,$i,"short_desc");
echo "$prodid, <b>$prodname</b>, $price<br>";
$i++;
//}
}
}
}Can anyone see what's going wrong here? I'm baffled...
Thanks in advance,
Matt