Advertisement
Guest User

Untitled

a guest
May 29th, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.81 KB | None | 0 0
  1. <?php while($row=mysqli_fetch_array($result)) { ?>
  2. <div id="item">
  3. <form method="post" action="cartReceiver.php">Quantity:
  4. <?php echo '<img height="200" width="200" src="data:image;base64,'.$row[2]. '">';?>
  5. </br>
  6. <?php echo $row[ "name"];?>
  7. </br>
  8. <?php echo $row[ "price"];?>
  9. </br>
  10. <?php echo $row[ "description"];?>
  11. </br>
  12. <input type="text" value="" name="quantity" />
  13. </br>
  14. <input type="submit" value="add to cart" name="cart" />
  15. </form>
  16. </div>
  17. <?php }//end of while ?>
  18.  
  19. <?php
  20. if (isset($_POST[ "cart"])){
  21. $addtoname=$_SESSION[ 'username'];
  22. $addtoprice=$row[ 'price'];
  23. $addtodiscount=$row[ 'discount'];
  24. $addtoid=$row[ 'id'];
  25. $addtoimage=$row[ 'image'];
  26. $addtoquantity=$_POST[ 'quantity'];
  27. $hostname="localhost" ;
  28. $username="root";
  29. $password="" ;
  30. $database="myproject" ; $con=mysqli_connect($hostname,$username,$password,$database) or die(mysqli_error());
  31. $select=mysqli_select_db($con, "myproject")or die( "cannnot select db"); mysqli_query($con,"INSERT INTO cart(username,quantity,price,image,id,discount) VALUES('$addtoname','$addtoquantity','$addtoprice','$addtoimage','$addtoid','$addtodiscount')");
  32. echo "success";
  33. }
  34. else{
  35. echo "fail";
  36. }
  37.  
  38. <?php while($row=mysqli_fetch_array($result)) { ?>
  39. <div id="item">
  40. <form method="post" action="cartReceiver.php">Quantity:
  41. <?php echo '<img height="200" width="200" src="data:image;base64,'.$row[2]. '">';?>
  42. </br>
  43. <input type="text" name="name" value=" <?php echo $row[ "name"];?>" readonly />
  44. </br>
  45. <input type="text" name="price" value="<?php echo $row[ "price"];?>" readonly />
  46. </br>
  47. <input type="text" name="description" value="<?php echo $row[ "description"];?>" readonly />
  48. </br>
  49. <input type="text" value="" name="quantity" />
  50. </br>
  51. <input type="submit" value="add to cart" name="cart" />
  52. </form>
  53. </div>
  54. <?php }//end of while ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement