Advertisement
Nautiluss

search

May 14th, 2024
705
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.26 KB | None | 0 0
  1. <?php
  2. $host = 'localhost';
  3. $username = 'root';
  4. $password = '';
  5. $database = 'forum';
  6. $conn = new mysqli($host, $username, $password, $database);
  7.  
  8.  
  9. if ($conn->connect_error) {
  10.     die("Ошибка подключения к базе данных: " . $conn->connect_error);
  11. }
  12.  
  13.  
  14. $query = $_GET['query'];
  15.  
  16.  
  17. $sql = "SELECT * FROM messages WHERE message_text LIKE '%$query%'";
  18. $result = $conn->query($sql);
  19.  
  20.  
  21. if ($result->num_rows > 0) {
  22.     while($row = $result->fetch_assoc()) {
  23.         echo "<a class='wow' href='topic.php?id=".$row["topic_id"]."'>Номер топика: " . $row['topic_id'] . " - Сообщение: " . $row['message_text'] . "<br>";
  24.  
  25.     }
  26. } else {
  27.     echo "Ничего не найдено";
  28. }
  29.  
  30.  
  31. $conn->close();
  32. ?>
  33. <!DOCTYPE html>
  34. <html id="suka">
  35. <head>
  36.     <title>Messages</title>
  37.     <link rel="stylesheet" type="text/css" href="style.css">
  38.     <link rel="stylesheet" href="fonts/fonts.css">
  39. </head>
  40. <body style="background: #11191F; display: flex; justify-content: center; position:relative; left:25%; align-items: center; height: 100vh; flex-direction: column;">
  41.      <script src="./src/visual/dop.js"></script>
  42.      <script src="./src/visual/back.js"></script>
  43.      <script src="./src/visual/app.js"></script>
  44. </body>
  45. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement