Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $.ajax({
- type: "POST",
- url: "new1.php",
- dataType: "json",
- data: { name: $('#name-typed').val()},
- success: function(response) {
- $('.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> ')
- }
- });
- <?php
- $servername = "localhost";
- $username = "root";
- $password = "";
- // Create connection
- $conn = new mysqli($servername, $username, $password,"mydb");
- // Check connection
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- $sql = "SELECT id FROM names";
- $result = $conn->query($sql);
- $jsonData = array();
- while ($array = mysql_fetch_row($result)) {
- $jsonData['id'] = $array;
- }
- echo json_encode($jsonData);
- else {
- echo "0 results";
- }
- $conn->close();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement