Advertisement
Guest User

Untitled

a guest
Feb 7th, 2016
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. $.ajax({
  2. type: "POST",
  3. url: "new1.php",
  4. dataType: "json",
  5. data: { name: $('#name-typed').val()},
  6. success: function(response) {
  7. $('.cartcontainer').append(' <div class="cartproduct"><img src="images/deletesm.png" height="18" width="18" alt="deleteproduct" id="delete" data-toggle="tooltip" data-placement="bottom" title="Delete Product"/><span class="cartlist"><span><img src="images/wheatthumbnail.png" alt="ricethumbnail" class="cartcontent thmbnail" /></span><ul class="cartcontent"><li class="col"> </li><li class="col">'+ response.id + '</li><li class="crtqtymanuplator"><button>-</button><input type="text" id="crtcountholder" /><button>+</button></li></ul></span></div> ')
  8. }
  9. });
  10.  
  11. <?php
  12.  
  13.  
  14. $servername = "localhost";
  15. $username = "root";
  16. $password = "";
  17.  
  18. // Create connection
  19. $conn = new mysqli($servername, $username, $password,"mydb");
  20.  
  21. // Check connection
  22. if ($conn->connect_error) {
  23. die("Connection failed: " . $conn->connect_error);
  24. }
  25. $sql = "SELECT id FROM names";
  26. $result = $conn->query($sql);
  27. $jsonData = array();
  28.  
  29. while ($array = mysql_fetch_row($result)) {
  30. $jsonData['id'] = $array;
  31. }
  32. echo json_encode($jsonData);
  33. else {
  34. echo "0 results";
  35. }
  36. $conn->close();
  37. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement