I am trying to create a shopping cart to my php application i already write this code it gives me this error Invalid argument supplied for foreach()
and it doesn't retrive the data that are in the database
code is looks like this
<?php
include('../Neo/assets/session.inc.php');
include 'config/config.php';
if (!$con) {
die("Connection failed: " . mysqli_connect_error());
}
$last_id = mysqli_insert_id($con);
$_SESSION['last_id'] = $last_id;
$sql = "SELECT * FROM product_order WHERE ord_id =" . $last_id;
$result = mysqli_query($con,$sql);
$row = mysqli_fetch_assoc($result);
?>
<?php
foreach($row as $i){
echo
'<tr>
<td> '.$i['ord_id'].'</td>
<td> '.$i['card_id'].'</td>
<td> '.$i['field1'].'</td>
<td> '.$i['field2'].'</td>
<td> '.$i['field3'].'</td>
<td> '.$i['field4'].'</td>
<td> '.$i['field5'].'</td>
<td> '.$i['ord_qty'].'</td>
<td> '.$i['card_price'].'</td>
<td> '.$i['ord_total'].'</td>
</tr>';
}
?>