Advertisement
Guest User

Untitled

a guest
Jan 19th, 2014
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. <?php
  2. include("includes/db.php");
  3. include("includes/functions.php");
  4.  
  5. if($_REQUEST['command']=='add' && $_REQUEST['productid']>0){
  6. $pid=$_REQUEST['productid'];
  7. addtocart($pid,1);
  8. header("location:shoppingcart.php");
  9. exit();
  10. }
  11. ?>
  12. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  13. <html xmlns="http://www.w3.org/1999/xhtml">
  14. <head>
  15. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  16. <title>Products</title>
  17. <script language="javascript">
  18. function addtocart(pid){
  19. document.form1.productid.value=pid;
  20. document.form1.command.value='add';
  21. document.form1.submit();
  22. }
  23. </script>
  24. </head>
  25.  
  26.  
  27. <body>
  28. <form name="form1">
  29. <input type="hidden" name="productid" />
  30. <input type="hidden" name="command" />
  31. </form>
  32. <div align="center">
  33. <h1 align="center">Products</h1>
  34. <table border="0" cellpadding="2px" width="600px">
  35. <?php
  36. $result=mysqli_query($db,"SELECT * FROM products");
  37. while($row=mysqli_fetch_array($result)){
  38. ?>
  39. <tr>
  40. <td><img src="<?php echo $row['picture']?>" /></td>
  41. <td> <b><?php echo $row['name']?></b><br />
  42. <?php echo $row['description']?><br />
  43. Price:<big style="color:green">
  44. $<?php echo $row['price']?></big><br /><br />
  45. <input type="button" value="Add to Cart" onclick="addtocart(<?=$row['serial']?>)" />
  46. </td>
  47. </tr>
  48. <tr><td colspan="2"><hr size="1" /></td>
  49. <?php } ?>
  50. </table>
  51. </div>
  52. </body>
  53. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement