$order=mysql_query("SELECT * FROM `order_details` WHERE id='".$_GET['id']."'") or die(mysql_error());
$orderArray=mysql_fetch_array($order);
$productId=explode(',',$orderArray['product_id']);
$productId=(array_values($productId));
$quantityId=explode(',',$orderArray['quantity']);
$quantityId=(array_values($quantityId));
print_r($quantityId);
$i=0;
foreach($productId as $id)
{
$i++;
//echo "SELECT * FROM products WHERE id=$id";
$productId=mysql_query("SELECT * FROM products WHERE id=$id");
$productArray=mysql_fetch_array($productId);
?>
<tr>
<td><?php echo $i;?></td>
<td>
<?php echo $productArray['name'];?>
</td>
<td>
<?php echo $productArray['price'];?>
</td>
<td>
<?php
for($j=0;$j<count($quantityId);$j++){
echo $quantityId[$j];
}
?>
</td>
<td>
<?php
echo $orderArray['price'];
?>
</td>
</tr>
<?php
}
?>
I want to show the quantity one by one the inside the loop and as there is a count function inside the loop it prints the total quantity inside
My output:
Sl No. Name Price Quantity
1 watches2 100 12
2 pens1 100 12
desired output:
Sl No. Name Price Quantity
1 watches2 100 1
2 pens1 100 2