Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. <script src="jquery-3.1.0.min.js"></script>
  2. <script>
  3. $(document).ready(function() {
  4. $('#submit').click(function(e){
  5. e.preventDefault();
  6. $.ajax({
  7. type:"POST",
  8. data:{idheadcode: $('#headcode').val(), idlocation: $('#location').val()},
  9. url: "headcode_Db_connect.php",
  10. success: function(data){
  11. $("#content").html(data);
  12. }
  13. });
  14. });
  15. });
  16. </script>
  17. </head>
  18. <body>
  19. <form name="input">
  20. HeadCode: <input type="text" id="headcode">
  21. End Location:<input type="text" id="location">
  22. <input type="submit" id="submit">
  23. </form>
  24. <div id="content"></div>
  25.  
  26. <?php
  27. $headcode = $_POST['headcode'];
  28. $location = $_POST['location'];
  29.  
  30. $host="localhost"; // Host name
  31. $username="root"; // Mysql username
  32. $password="789852"; // Mysql password
  33. $db_name="work"; // Database name
  34. $tbl_name = "headcodes";
  35.  
  36. // Connect to server and select database.
  37. $link = mysql_connect("$host", "$username", "$password")or die("cannot connect");
  38. mysql_select_db("$db_name")or die("cannot select DB");
  39.  
  40. $sql = "SELECT * FROM $tbl_name WHERE headcode= '$headcode'AND (location1= '$location' OR location2 = '$location' OR location3= '$location' OR location4 = '$location' OR location5 = '$location')" ;
  41. $result1 = mysql_query($sql, $link);
  42.  
  43. if($result1){
  44. //echo "Successful";
  45. }
  46. else {
  47. echo "ERROR";
  48. }
  49. while ($row = mysql_fetch_assoc($result1)){
  50. $number = $row['number'];
  51. }
  52.  
  53. $myJson = json_encode ($number);
  54. echo $number;
  55. echo "10";
  56.  
  57. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement