Advertisement
Guest User

Untitled

a guest
Jul 15th, 2016
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.81 KB | None | 0 0
  1. <script type="text/javascript" src="jquery.js"></script>
  2. <script type="text/javascript">
  3. $(document).ready(function(){
  4. $('#search').keyup(function(){
  5. var sea = $('#search').val();
  6. $.get('test.php',{getsearch:sea},function(data){
  7. $('#result').show().html(data);
  8. });
  9. });
  10.  
  11. $('#search').blur(function(){
  12. $('#result').hide();
  13. });
  14.  
  15. });
  16. </script>
  17. </head>
  18. <body>
  19. <div class="cover">
  20. <div class="btns-holder">
  21. <input type="search" name="s" placeholder="Search for something.." id="search" autocomplete="off" /><input type="submit" name="sub" value="" id="sub" />
  22. </div>
  23. </div>
  24.  
  25.  
  26.  
  27. <div id="result">
  28. </div>
  29. <?php
  30. $post = @$_GET['p'];
  31. $que = "SELECT * FROM `search` WHERE `id`='$post'";
  32. $run = mysqli_query($con,$que);
  33. while($row=mysqli_fetch_array($con,$que)):
  34.  
  35. ?>
  36. <img src="<?php echo $row['image']; ?>" widrh="500px" height="450px" style="float: left;"></img>
  37. <h2 style="font-family: sans-serif;"><?php echo $row['title']; ?></h2>
  38. <?php endwhile; ?>
  39. </body>
  40.  
  41. <?php
  42. $host = "localhost";
  43. $user = "root";
  44. $pass = "";
  45. $db = "ajax_search";
  46. $con = mysqli_connect($host, $user, $pass, $db);
  47. if(mysqli_connect_errno())
  48. {
  49. echo "connection failed".mysqli_connect_error();
  50. }
  51.  
  52. $search = @$_GET['getsearch'];
  53. $que = "SELECT * FROM `search` WHERE `title` LIKE '%$search%'";
  54. $run = mysqli_query($con,$que);
  55.  
  56. while($row=mysqli_fetch_assoc($run)):
  57. ?>
  58.  
  59. <a href="search.php?p=<?php echo $row['id']; ?>">
  60. <div class="container">
  61. <img src="<?php echo $row['image']; ?>" width="50px" height="45px"></img>
  62. <h3><?php echo $row['title']; ?></h3></br>
  63. </div>
  64. </a>
  65. <?php endwhile; ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement