Jump to content

Code Help Please


kerbdog

Recommended Posts

Hi Requnix

 

No I am posting code in php.  Full code below....

 

<?php
//Script to delete product from cart.
  if(isset($_POST['submit']))
  {

$itemname = $_POST['h1'];
//echo $_SESSION['itemname'][$itemname];
  unset($_SESSION['itemqty'][$itemname]);
  unset($_SESSION['itemprice'][$itemname]);
  unset($_SESSION['itemname'][$itemname]);
  
}
  echo "<br/><br/>";
  echo "<table border='8' cellpadding='10' id='shopping_cart'>";
  echo '<tr><form id="t1" method="post" action="summary.php" name="t1"><input type="submit" name="order" value="SUBMIT ORDER"></tr>';
  echo "<tr><th bgcolor=#efefef>Date of Order</th bgcolor=#efefef>
  <th bgcolor=#efefef>Name</th>
  <th bgcolor=#efefef>Quantity</th>
  <th bgcolor=#efefef>Price</th>
  <th colspan='2'bgcolor=#efefef>Subtotal</th></tr>";
  $date = date('h:i a , Dd M Y');
  foreach($_SESSION['itemname'] as $key => $value)
  
{
//Loop sum of Subtotals to produce Grand Total
$total += $_SESSION['itemqty'][$key] * $_SESSION['itemprice'][$key];

//Table showing Item Id reference, price per item and subtotal
echo
'<tr>
<td>'.$date.'</td>
<td>'.$_SESSION['itemname'][$key].'</td>
<td><input type="text" name="t1" value='.$_SESSION['itemqty'][$key].'></td>
<td>$'.$_SESSION['itemprice'][$key].'</td>
<td header="subtotal">$'.($_SESSION['itemqty'][$key] * $_SESSION['itemprice'][$key]).'</td>
<td><form id="f1" method="post" name="f1"><input type="submit" name="submit" value = "delete"><input type="hidden" name="h1" value='.$key.'></td>
</tr>
';

}
//Echoing Grand total.
  echo '
  <tr>
<td colspan="4" bgcolor=#efefef><b>GRAND TOTAL</b></td><td colspan="2" bgcolor=#efefef><b>$'.$total.'</b></td>
  </table>
';

?>

Link to comment
https://forums.phpfreaks.com/topic/228234-code-help-please/#findComment-1176981
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.