Mario_Hansen

Versicherung_php2

May 1st, 2016
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.31 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3.     <head>
  4.         <title>Versicherung</title>
  5.         <meta charset="utf-8">
  6.         <meta name="versicherung" content="width=device-width, initial-scale=1.0">
  7.         <link rel="stylesheet" type="text/css" href="styles.css"/>
  8.     </head>
  9.         <body>
  10.             <?php
  11.        
  12.                 $suchauswahl = $_POST['suchauswahl'];
  13.                 $suchbegriff = $_POST['suchbegriff'];
  14.                
  15.                
  16.                 $suchauswahl = addslashes($suchauswahl);
  17.                
  18.                
  19.                
  20.                 $db = new mysqli("localhost","supermario","1234","versicherung");
  21.                 if (mysqli_connect_errno())
  22.                 {
  23.                     echo "Fehler bei der Verbindung zur Datenbank";
  24.                     echo mysqli_connect_error();
  25.                     exit;
  26.                 }
  27.                
  28.                
  29.                 // Ausgabe "Alle Fahrzeuge"
  30.                 if ($suchauswahl == 'alle Fahrzeuge')
  31.                 {
  32.                     $abfrage = "SELECT Hersteller, Typ FROM fahrzeug";
  33.                 }
  34.                 $ergebnis = $db->query($abfrage);
  35.                 $anz_ergebnis = mysqli_num_rows($ergebnis);
  36.                 if($suchauswahl == 'alle Fahrzeuge')
  37.                 {
  38.                     echo "<table><thead><td>Position</td><td>Fahrzeughersteller</td><td>Typ</td></thead>";
  39.                     $i=1;
  40.                     while($row = mysqli_fetch_assoc($ergebnis))
  41.                     {
  42.                         echo"<tbody><tr><td>".($i)."</td><td>".stripslashes($row["Hersteller"])."</td><td>".stripslashes($row["Typ"])."</tr></tbody>";
  43.                         $i++;
  44.                     }
  45.                     echo "</table>";
  46.                 }
  47.                
  48.                
  49.                
  50.             ?>
  51.            
  52.         </body>
  53. </html>
Advertisement
Add Comment
Please, Sign In to add comment