kerbdog Posted February 11, 2011 Share Posted February 11, 2011 Hi I am having issues with the following code. I cannot get the table to produce a subtotal multiplying the value of 'ITEMQTY' which is a text field in the form in which the user enters by the 'ITEMPRICE' field which value is located in a text document. <h1>SHOPPING CART</h1><img src="images/cart.png" alt="Cart" width="100" height="100"/> <a href="browse_index.php">CLICK HERE TO CONTINUE SHOPPING</a> <?php 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' >"; echo "<tr><th>Name</th><th>Quantity</th><th>Price</th><th>Subtotal</th></tr>"; foreach($_SESSION['itemname'] as $key => $value) $subtotal = ($_SESSION['itemprice']*($_SESSION['itemqty']; { echo '<tr> <td>'.$_SESSION['itemname'][$key].'</td> <td><input type="text" name="t1" value='.$_SESSION['itemqty'][$key].'></td> <td>'.$_SESSION['itemprice'][$key].'</td> <td>'.$_SESSION['h2'][$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> <tr><form id="t1" method="post" action="summary.php" name="t1"><input type="submit" name="order" value="SUBMIT ORDER"></tr>'; } echo "</table>"; ?> [attachment deleted by admin] Link to comment https://forums.phpfreaks.com/topic/227344-problems-with-totaling-values-in-table-using-session-variables/ Share on other sites More sharing options...
Pikachu2000 Posted February 12, 2011 Share Posted February 12, 2011 I haven't gone through all of your code, but let's start with the obvious. None of the value= attributes in your form are quoted, and you're attempting to nest <form> tags, thereby invalidating the markup. Link to comment https://forums.phpfreaks.com/topic/227344-problems-with-totaling-values-in-table-using-session-variables/#findComment-1173062 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.