hye, can anyone teach me how to insert the session displayed in db..
Here are the code that display the order..
function showOrder() {
global $conn;
$order = $_SESSION['order'];
if ($order) {
$items = explode(',',$order);
$contents = array();
foreach ($items as $item) {
$contents[$item] = (isset($contents[$item])) ? $contents[$item] + 1 : 1;
}
$output[] = '<form action="previeworder.php?action=update" method="post" MenuID="order">';
$output[] = '<table>';
foreach ($contents as $MenuID=>$qty)
{
$result = mysql_query("SELECT * FROM menu WHERE MenuID= '".$MenuID."' ");
$row = mysql_fetch_array($result);
//extract($row);
$output[] = '<tr>';
$output[] = '<td><a href="previeworder.php?action=delete&MenuID='.$MenuID.'" class="r">Remove</a></td>';
$name = $row['Name'];
$output[] = '<td>'.$name.'</td>';
$price = $row['Price'];
$output[] = '<td>'.$price.'</td>';
$output[] = '<td><input type="text" name="qty'.$MenuID.'" value="'.$qty.'" size="3" maxlength="3" /></td>';
$subtotal = $row['Price'] * $qty;
$output[] = '<td>RM '.$subtotal.'</td>';
//$total='0';
$total = $total + $row['Price'] * $qty;
$output[] = '</tr>';
$_SESSION['name'] = $name;
$_SESSION['price'] = $price;
$_SESSION['qty'] = $qty;
$_SESSION['subtotal'] = $subtotal;
$_SESSION['total'] = $total;
}
$output[] = '</table>';
$output[] = '<p>Grand total: RM <strong>'.$total.'</strong></p>';
$output[] = '<div><button type="submit">Update Order</button></div>';
$output[] = '</form>';
}
else
{
$output[] = '<p>Your menu list is empty.</p>';
}
return join('',$output);
}
I want it to save the names, quantity of each order, price of each order, subtotal n total.. say that my db is ros and table is orderrecord.