Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. <?php
  2. $connection = mysqli_connect('localhost', "my_user", "my_password", "my_db");
  3. $output = '';
  4. if(isset($_POST['search'])) {
  5. $searchkey = $_POST['search'];
  6. $searchkey = preg_replace("/[^0-9a-z]/i", "", $searchkey);
  7. //echo $searchkey;
  8. $query = mysqli_query($connection,"SELECT * FROM building_tc WHERE profile LIKE '%$searchkey%' OR server LIKE '%$searchkey%'") or die("Не удалось найти!");
  9. $count = mysqli_num_rows($query);
  10. //echo $count;
  11. if($count == 0) {
  12. $output = "Нет результатов поиска!";
  13. }
  14. else {
  15. while($row=mysqli_fetch_array($query)) {
  16. $profile = $row['profile'];
  17. $server = $row['server'];
  18. $output .= '<div>'.$profile.''.$server.'</div>';
  19. }
  20. }
  21. echo "$output";
  22. }
  23. ?>
  24. <form action="" method="post"> <input type="text" name="search" placeholder="Search"> <input type="submit" value="Поиск" /></form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement