Advertisement
Guest User

Untitled

a guest
Jun 1st, 2016
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.16 KB | None | 0 0
  1.  
  2. <?php
  3. session_start();
  4. ?>
  5. <html>
  6. <head>
  7. <title> Choose roducts </title>
  8. <link rel="stylesheet" type="text/css" href="highlight_file.css"/>
  9. </head>
  10. <body>
  11. <form action="final.php" method="post">
  12. <?php
  13. //Redirect to orderprotein.php if orderid not set.
  14. if(!isset($_SESSION["orderid"])){
  15. header("Location: chooseproducts.php");
  16. die();
  17. }
  18. if(!isset($_POST['prodid'])){
  19. header("Location: chooseproducts.php");
  20. die();
  21. }
  22.  
  23. //Gather all data from the orderpizza.php page
  24. $productid=$_POST['prodid'];
  25. $orderid=$_SESSION["orderid"];
  26. $quantity = $_POST['quantity'];
  27. echo 'quantity: '.$quantity;
  28.  
  29. //Provide Database connection
  30. $dbhost = 'localhost:3306'; //hostname:port number
  31. $dbuser = 'root'; //username
  32. $dbpass = ''; //password
  33. $conn = mysql_connect($dbhost, $dbuser, $dbpass); //returns true or false
  34. if(! $conn )////display error message if connection fails
  35. {
  36. die('Could not connect: ' . mysql_error());
  37. }
  38.  
  39.  
  40.  
  41. //DISPLAY TOPPINGS ON THE PAGE
  42. $sql = 'SELECT * FROM PRODUCTS WHERE PRODUCTID ="'.$productid.'"';
  43. //select your database
  44. mysql_select_db('supplement');
  45.  
  46.  
  47. //run your query
  48. $retval = mysql_query( $sql, $conn );
  49.  
  50.  
  51. if(! $retval )
  52. {
  53. die('Could not enter data: ' . mysql_error());
  54. }
  55.  
  56. //DISPLAY RECORDS IN TABLE FORMAT
  57. echo '<center><h2>Shopping Cart <br/></h2></center>';
  58. echo '<table>';
  59. while($row = mysql_fetch_array($retval, MYSQL_NUM)){
  60. //records of the items in the shopping cart
  61.  
  62. echo '<table border="2">
  63. <tr>
  64. <td> <p> PRODUCT </p> </td>
  65. <td> <p> PRODUCTID </p> </td>
  66. <td> <p> DESCRIPTION </p> </td>
  67. <td> <p> QUANTITY </p> </td>
  68. <td> <p> PRICE </p> </td>
  69. </tr>';
  70. echo '<td> <img src="'.$row[5].'" name="prodid" width="150" height="150"/> </td>';
  71. echo '<td> <p>"sdfs"<p/></td>';
  72. echo '<td>Product Description <p>'.$row[6].'<p/></td>';
  73.  
  74. echo '<td> <p>'.$row[2].'</p></td></tr>';
  75. }
  76. echo '</table>';
  77.  
  78.  
  79. echo '<input type="Submit" value="add this to cart" Name= "add this to cart"/>';
  80. echo '<br/><br/><a href="orderprotein.php"> Click here to change your Product <a>';
  81.  
  82.  
  83.  
  84. mysql_free_result($retval);
  85. mysql_close($conn);
  86.  
  87.  
  88. ?>
  89. </form>
  90. </body>
  91. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement