kamran193 Posted January 5, 2012 Share Posted January 5, 2012 can some help to get the table to repeat and close the table with echo "</table>" dunno where to place it function cart () { print "<table id='producttable' border='1'>". "<tr>". "<td class='td top'>Delete</td>". "<td class='td top'>Product Name</td>". "<td class='td top'>Quantity</td>". "<td class='td top'>Price</td>". "<td class='td top'>Sub Total</td>". "</tr>"; foreach($_SESSION as $name => $value) { if ($value>0) { if (substr($name, 0, 5) == "cart_") { $productid = substr($name, 5, (strlen($name)-5)); $query = mysql_query('SELECT * FROM product WHERE ProductID =' .$productid); while ($query_row = @mysql_fetch_array($query)) { $sub = $query_row["Price"] * $value; print "<tr>". "<td class='td'><a href='./cart.php?delete=".$productid."'> [Delete] </a></td>". "<td class='td'>".$query_row["Name"]."</td>". "<td class='td'>".$value."</td>". "<td class='td'>".$query_row["Price"]."</td>". "<td class='td'>".$sub."</td>". "</tr>"; } echo "</table>"; } @$total += $sub; } } if (@$total==0) { echo "<p>Your basket is empty</p>"; } else { echo @" Total: £" .$total; ?> <form action="https://www.paypal.com/cgi-bin/webscr" method="post"> <input type="hidden" name="cmd" value="_cart"> <input type="hidden" name="upload" value="1"> <input type="hidden" name="business" value="[email protected]"> <?php paypal_items(); ?> <input type="hidden" name="currency_code" value="GBP"> <input type="hidden" name="amount" value="<?php echo $total; ?>"> <input type="image" src="http://www.paypal.com/en_US/i/btn/x-click-but03.gif" name="submit" alt="Make payments with PayPal - it's fast, free and secure!"> </form> <?php } echo "</table>"; } Link to comment https://forums.phpfreaks.com/topic/254449-php-table-help/ Share on other sites More sharing options...
gristoi Posted January 6, 2012 Share Posted January 6, 2012 function cart () { print "<table id='producttable' border='1'>". "<tr>". "<td class='td top'>Delete</td>". "<td class='td top'>Product Name</td>". "<td class='td top'>Quantity</td>". "<td class='td top'>Price</td>". "<td class='td top'>Sub Total</td>". "</tr>"; foreach($_SESSION as $name => $value) { if ($value>0) { if (substr($name, 0, 5) == "cart_") { $productid = substr($name, 5, (strlen($name)-5)); $query = mysql_query('SELECT * FROM product WHERE ProductID =' .$productid); while ($query_row = @mysql_fetch_array($query)) { $sub = $query_row["Price"] * $value; print "<tr>". "<td class='td'><a href='./cart.php?delete=".$productid."'> [Delete] </a></td>". "<td class='td'>".$query_row["Name"]."</td>". "<td class='td'>".$value."</td>". "<td class='td'>".$query_row["Price"]."</td>". "<td class='td'>".$sub."</td>". "</tr>"; } } @$total += $sub; } } print "</table>"; if (@$total==0) { echo "<p>Your basket is empty</p>"; } else { echo @" Total: £" .$total; ?> <form action="https://www.paypal.com/cgi-bin/webscr" method="post"> <input type="hidden" name="cmd" value="_cart"> <input type="hidden" name="upload" value="1"> <input type="hidden" name="business" value="[email protected]"> <?php paypal_items(); ?> <input type="hidden" name="currency_code" value="GBP"> <input type="hidden" name="amount" value="<?php echo $total; ?>"> <input type="image" src="http://www.paypal.com/en_US/i/btn/x-click-but03.gif" name="submit" alt="Make payments with PayPal - it's fast, free and secure!"> </form> <?php } } Link to comment https://forums.phpfreaks.com/topic/254449-php-table-help/#findComment-1304819 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.