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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.