Advertisement
Guest User

Untitled

a guest
Jul 12th, 2016
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.05 KB | None | 0 0
  1. <script type="text/javascript">
  2. function showUser($id){
  3.  
  4. $("#email").keyup(function(){
  5. $.ajax({
  6. type: "POST",
  7. url: "http://localhost/cart/guser.php",
  8. data:'keyword='$id,
  9. success: function(data){
  10. $("#txtHint").html(data);
  11.  
  12. }
  13. });
  14. });
  15. }
  16. </script>
  17.  
  18. <!DOCTYPE html>
  19. <html>
  20. <body>
  21.  
  22. <form>
  23. enter digit :
  24. <input type="text" id="id" name="id" onkeyup='showUser(this.value)'/>
  25. <br />
  26.  
  27.  
  28. </form>
  29. <br>
  30. <div id="txtHint"><b>Person info will be listed here...</b>
  31. </div>
  32.  
  33. <script>
  34. function showUser(id) {
  35. httpRequest = new XMLHttpRequest();
  36.  
  37. if (!httpRequest) {
  38. alert('Giving up :( Cannot create an XMLHTTP instance');
  39. return false;
  40. }
  41. else
  42. {
  43.  
  44. httpRequest.onreadystatechange = function() {
  45. if (httpRequest.readyState == 4 && httpRequest.status == 200) {
  46. document.getElementById("txtHint").innerHTML = httpRequest.responseText;
  47. }
  48. };
  49. httpRequest.open("GET", "localhost/cart/guser.php?id=" + id, true);
  50. httpRequest.send();
  51. }
  52.  
  53. }
  54. </script>
  55.  
  56. </body>
  57. </html>
  58.  
  59. <!DOCTYPE html>
  60. <html>
  61. <head>
  62. <style>
  63. table {
  64. width: 100%;
  65. border-collapse: collapse;
  66. }
  67.  
  68. table, td, th {
  69. border: 1px solid black;
  70. padding: 5px;
  71. }
  72.  
  73. th {text-align: left;}
  74. </style>
  75. </head>
  76. <body>
  77.  
  78. <?php
  79. $id = intval($_GET['id']);
  80.  
  81. $servername = "localhost";
  82. $username = "root";
  83. $password = "";
  84. $dbname = "cart";
  85.  
  86. $conn = mysqli_connect($servername, $username, $password, $dbname);
  87.  
  88. if (mysqli_connect_errno())
  89. {
  90. echo "Failed to connect to MySQL: " . mysqli_connect_error();
  91. }
  92.  
  93.  
  94. mysqli_select_db('cart',$con);
  95.  
  96. $sql="SELECT * FROM user_details WHERE id = '".$id."'";
  97. $result = mysqli_query($con,$sql);
  98.  
  99. echo "<table>
  100. <tr>
  101. <th>Firstname</th>
  102. <th>Lastname</th>
  103. <th>email</th>
  104. </tr>";
  105. while($row = mysqli_fetch_array($result)) {
  106. echo "<tr>";
  107. echo "<td>" . $row['FirstName'] . "</td>";
  108. echo "<td>" . $row['LastName'] . "</td>";
  109. echo "<td>" . $row['email'] . "</td>";
  110. echo "</tr>";
  111. }
  112. echo "</table>";
  113. mysqli_close($con);
  114. ?>
  115. </body>
  116. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement