Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <title>Bildungslykke - Suche</title>
- </head>
- <body>
- <form action="#" method="GET">
- <input type="text" name="suchfeld" placeholder="Ihre Suchanfrage..."/>
- <input type="submit" name="suche_enter" value="suchen"/>
- </form>
- <hr /><br />
- <?php
- if(isset($_GET['suche_enter']) && !empty($_GET['suchfeld']))
- {
- $host = "localhost";
- $user = "root";
- $pass = "";
- $db = "test_db";
- $conn = new mysqli($host,$user,$pass,$db);
- if($conn->connect_errno)
- {
- die("Verbindung fehlgeschlagen: " . $conn->connect_error);
- }
- $suchbegriff = trim(htmlentities(stripslashes(mysqli_real_escape_string($conn, $_GET['suchfeld']))));
- $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";
- $query = mysqli_query($conn, $sql);
- echo "<ul>";
- WHILE($row = mysqli_fetch_assoc($query))
- {
- $headline = $row['headline'];
- $overtext = $row['overtext'];
- $text = $row['text'];
- echo "<li>" . $headline . "<br /><br />" . $overtext . "<br /><br /><hr /><br /></li>";
- }
- echo "</ul>"; }
- ?>
- </body>
- </html>
Add Comment
Please, Sign In to add comment