Guest User

Untitled

a guest
Dec 29th, 2018
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.65 KB | None | 0 0
  1. <html>
  2.     <head>
  3.         <title>Bildungslykke - Suche</title>
  4.     </head>
  5.  
  6.     <body>
  7.         <form action="#" method="GET">
  8.             <input type="text" name="suchfeld" placeholder="Ihre Suchanfrage..."/>
  9.             <input type="submit" name="suche_enter" value="suchen"/>
  10.         </form>
  11.         <hr /><br />
  12.         <?php
  13.         if(isset($_GET['suche_enter']) && !empty($_GET['suchfeld']))
  14.         {
  15.             $host = "localhost";
  16.             $user = "root";
  17.             $pass = "";
  18.             $db = "test_db";
  19.             $conn = new mysqli($host,$user,$pass,$db);
  20.  
  21.             if($conn->connect_errno)
  22.             {
  23.                 die("Verbindung fehlgeschlagen: " . $conn->connect_error);
  24.             }
  25.  
  26.             $suchbegriff = trim(htmlentities(stripslashes(mysqli_real_escape_string($conn, $_GET['suchfeld']))));
  27.  
  28.  
  29.             $sql = "SELECT headline,text FROM article WHERE headline LIKE '%" . $suchbegriff . "%' OR image LIKE '%" . $suchbegriff . "%' OR overtext LIKE '%" . $suchbegriff . "%' OR text LIKE '%" . $suchbegriff . "%' OR gender1 LIKE '%" . $suchbegriff . "%' OR gender2 LIKE '%" . $suchbegriff . "%' ORDER BY headline,gender1,overtext,text,gender2,image ASC";
  30.             $query = mysqli_query($conn, $sql);
  31.  
  32.  
  33.             echo "<ul>";
  34.             WHILE($row = mysqli_fetch_assoc($query))
  35.             {
  36.                 $headline = $row['headline'];
  37.                 $overtext = $row['overtext'];
  38.                 $text = $row['text'];
  39.  
  40.                 echo "<li>" . $headline . "<br /><br />" . $overtext . "<br /><br /><hr /><br /></li>";
  41.             }
  42.             echo "</ul>"; }
  43.  
  44.  
  45.         ?>
  46.     </body>
  47. </html>
Add Comment
Please, Sign In to add comment