Ankündigung

Einklappen
Keine Ankündigung bisher.

Tabelle mit Datenbankabfrage filtern

Einklappen

Neue Werbung 2019

Einklappen
X
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

  • Tabelle mit Datenbankabfrage filtern

    Hallo zusammen,

    ich habe mit HTML eine Tabelle erstellt, die durch Links auf verschiedene Webseiten verweist. Durch ein Drop-Down-Menü soll diese Tabelle nun gefiltert werden und nur noch die Zeilen angezeigt werden, die zu der Auswahl des Formulars passen. Zur Zeit bleibt die Tabelle noch auf der Seite und über der Tabelle kommt eine weitere Tabelle mit den Ausgaben.

    Hier ist mein Quelltext:

    <?php include("includes/header.php");?>
    <body>
    <h1>Die 20 besten Cocktailrezepte</h1>
    <article>
    <header>
    <p>Nun geht's los: Verschaff dir einen Überblick über unsere fantastische und einzigartige Cocktailauswahl! Ein Klick auf den Cocktail bringt dich deinem Partyabend einen Schritt näher.</p>
    </header>
    <?php include("includes/nav.php");?>
    <section>
    <img src="bilder/bar.jpg" width="350" height="180" alt="Bildbar">
    <img src="bilder/haengematte.jpg" width="350" height="180" alt="Bildhängematte">
    <img src="bilder/kiwi.jpg" width="350" height="180" alt="Bildkiwi">
    <h3>Cocktailtabelle</h3>
    <form action="" method="post" name="register">
    Wähle deinen Geschmack aus und finde heraus, welche Cocktails für dich passen! Anschließend kannst du in der Tabelle auf deinen Cocktail klicken und das Rezept öffnen!<br/><br/>
    Geschmacksrichtung:
    <select name="Geschmack" size="1">
    <option value="0"> Wähle deinen Geschmack! </option>
    <option value="1"> scharf</option>
    <option value="2"> aromatisch </option>
    <option value="3"> würzig </option>
    <option value="4"> süß </option>
    <option value="5"> sauer </option>
    <option value="6"> erfrischend</option>
    <option value="7"> sahnig </option>
    <option value="8"> fruchtig </option>
    <option value="9"> herb </option>
    <option value="10"> prickelnd </option>
    <option value="11"> cremig </option>
    </select>
    <input type="submit" value="Filter anwenden" /></form>
    <br/>
    <?php
    include_once 'includes/DBManager.php';
    $dbm=new DBManager();

    //Geschmack
    if(isset ($_POST['Geschmack']) AND $_POST['Geschmack']=="1")
    {
    $sql= "SELECT `Name`, Beschreibung, Alkoholgehalt
    FROM `Cocktail`
    INNER JOIN Cocktail_has_Geschmacksrichtung
    ON Cocktail.idCocktail = Cocktail_has_Geschmacksrichtung.Cocktail_idCocktai l
    WHERE Geschmacksrichtung_idGeschmacksrichtung = 1";
    $dbm->datenausgabeSimple($sql);
    }

    if(isset ($_POST['Geschmack']) AND $_POST['Geschmack']=="2")
    {
    $sql= "SELECT `Name`, Beschreibung, Alkoholgehalt
    FROM `Cocktail`
    INNER JOIN Cocktail_has_Geschmacksrichtung
    ON Cocktail.idCocktail = Cocktail_has_Geschmacksrichtung.Cocktail_idCocktai l
    WHERE Geschmacksrichtung_idGeschmacksrichtung = 2";
    $dbm->datenausgabeSimple($sql);
    }

    if(isset ($_POST['Geschmack']) AND $_POST['Geschmack']=="3")
    {
    $sql= "SELECT `Name`, Beschreibung, Alkoholgehalt
    FROM `Cocktail`
    INNER JOIN Cocktail_has_Geschmacksrichtung
    ON Cocktail.idCocktail = Cocktail_has_Geschmacksrichtung.Cocktail_idCocktai l
    WHERE Geschmacksrichtung_idGeschmacksrichtung = 3";
    $dbm->datenausgabeSimple($sql);
    }

    if(isset ($_POST['Geschmack']) AND $_POST['Geschmack']=="4")
    {
    $sql= "SELECT `Name`, Beschreibung, Alkoholgehalt
    FROM `Cocktail`
    INNER JOIN Cocktail_has_Geschmacksrichtung
    ON Cocktail.idCocktail = Cocktail_has_Geschmacksrichtung.Cocktail_idCocktai l
    WHERE Geschmacksrichtung_idGeschmacksrichtung = 4";
    $dbm->datenausgabeSimple($sql);
    }

    if(isset ($_POST['Geschmack']) AND $_POST['Geschmack']=="5")
    {
    $sql= "SELECT `Name`, Beschreibung, Alkoholgehalt
    FROM `Cocktail`
    INNER JOIN Cocktail_has_Geschmacksrichtung
    ON Cocktail.idCocktail = Cocktail_has_Geschmacksrichtung.Cocktail_idCocktai l
    WHERE Geschmacksrichtung_idGeschmacksrichtung = 5";
    $dbm->datenausgabeSimple($sql);
    }

    if(isset ($_POST['Geschmack']) AND $_POST['Geschmack']=="6")
    {
    $sql= "SELECT `Name`, Beschreibung, Alkoholgehalt
    FROM `Cocktail`
    INNER JOIN Cocktail_has_Geschmacksrichtung
    ON Cocktail.idCocktail = Cocktail_has_Geschmacksrichtung.Cocktail_idCocktai l
    WHERE Geschmacksrichtung_idGeschmacksrichtung = 6";
    $dbm->datenausgabeSimple($sql);
    }

    if(isset ($_POST['Geschmack']) AND $_POST['Geschmack']=="7")
    {
    $sql= "SELECT `Name`, Beschreibung, Alkoholgehalt
    FROM `Cocktail`
    INNER JOIN Cocktail_has_Geschmacksrichtung
    ON Cocktail.idCocktail = Cocktail_has_Geschmacksrichtung.Cocktail_idCocktai l
    WHERE Geschmacksrichtung_idGeschmacksrichtung = 7";
    $dbm->datenausgabeSimple($sql);
    }

    if(isset ($_POST['Geschmack']) AND $_POST['Geschmack']=="8")
    {
    $sql= "SELECT `Name`, Beschreibung, Alkoholgehalt
    FROM `Cocktail`
    INNER JOIN Cocktail_has_Geschmacksrichtung
    ON Cocktail.idCocktail = Cocktail_has_Geschmacksrichtung.Cocktail_idCocktai l
    WHERE Geschmacksrichtung_idGeschmacksrichtung = 8";
    $dbm->datenausgabeSimple($sql);
    }

    if(isset ($_POST['Geschmack']) AND $_POST['Geschmack']=="9")
    {
    $sql= "SELECT `Name`, Beschreibung, Alkoholgehalt
    FROM `Cocktail`
    INNER JOIN Cocktail_has_Geschmacksrichtung
    ON Cocktail.idCocktail = Cocktail_has_Geschmacksrichtung.Cocktail_idCocktai l
    WHERE Geschmacksrichtung_idGeschmacksrichtung = 9";
    $dbm->datenausgabeSimple($sql);
    }

    if(isset ($_POST['Geschmack']) AND $_POST['Geschmack']=="10")
    {
    $sql= "SELECT `Name`, Beschreibung, Alkoholgehalt
    FROM `Cocktail`
    INNER JOIN Cocktail_has_Geschmacksrichtung
    ON Cocktail.idCocktail = Cocktail_has_Geschmacksrichtung.Cocktail_idCocktai l
    WHERE Geschmacksrichtung_idGeschmacksrichtung = 10";
    $dbm->datenausgabeSimple($sql);
    }

    if(isset ($_POST['Geschmack']) AND $_POST['Geschmack']=="11")
    {
    $sql= "SELECT `Name`, Beschreibung, Alkoholgehalt
    FROM `Cocktail`
    INNER JOIN Cocktail_has_Geschmacksrichtung
    ON Cocktail.idCocktail = Cocktail_has_Geschmacksrichtung.Cocktail_idCocktai l
    WHERE Geschmacksrichtung_idGeschmacksrichtung = 11";
    $dbm->datenausgabeSimple($sql);
    }
    ?>
    <table>
    <table border="1">
    <caption> Cocktailrezepte </caption>
    <tr>
    <th> Bezeichnung </th>
    <th> Schwierigkeitsgrad </th>
    <th> Alkohol? </th>
    </tr>
    <tr>
    <td> <a href="cocktailrezepte/bloodymary.php">Bloody Mary </a></td>
    <td>✰ ✰ ✰ ✰</td>
    <td> Ja! </td>
    </tr>
    <tr>
    <td> <a href="cocktailrezepte/caipirinha.php">Caipirinha </a> </td>
    <td> ✰ ✰</td>
    <td> Ja! </td>
    </tr>
    <tr>
    <td> <a href="cocktailrezepte/cinderella.php">Cinderella</a></td>
    <td> ✰ ✰ </td>
    <td> Nein! </td>
    </tr>
    <tr>
    <td> <a href="cocktailrezepte/cosmopolitan.php">Cosmopolitan </a></td>
    <td> ✰ ✰ ✰ ✰ ✰ </td>
    <td> Ja! </td>
    </tr>
    <tr>
    <td> <a href="cocktailrezepte/cubalibre.php">Cuba Libre </a></td>
    <td> ✰ ✰ ✰</td>
    <td> Ja! </td>
    </tr>
    <tr>
    <td> <a href="cocktailrezepte/hurricane.php">Hurricane</a></td>
    <td> ✰ ✰ ✰ ✰</td>
    <td> Ja! </td>
    </tr>
    <tr>
    <td> <a href="cocktailrezepte/ipanema.php">Ipanema </a></td>
    <td> ✰ </td>
    <td> Nein! </td>
    </tr>
    <tr>
    <td> <a href="cocktailrezepte/longislandicetea.php">Long Island Icetea</a></td>
    <td> ✰ ✰ ✰ ✰ </td>
    <td> Ja! </td>
    </tr>
    <tr>
    <td> <a href="cocktailrezepte/maitai.php">Mai-Tai </a></td>
    <td> ✰ ✰ ✰</td>
    <td> Ja! </td>
    </tr>
    <tr>
    <td> <a href="cocktailrezepte/malibubeach.php">Malibu Beach</a></td>
    <td> ✰</td>
    <td> Ja! </td>
    </tr>
    <tr>
    <td> <a href="cocktailrezepte/margarita.php">Margarita </a></td>
    <td> ✰ ✰ ✰ ✰ ✰</td>
    <td> Ja! </td>
    </tr>
    <tr>
    <td> <a href="cocktailrezepte/mojito.php">Mojito </a></td>
    <td> ✰ ✰ ✰ </td>
    <td> Ja! </td>
    </tr>
    <tr>
    <td> <a href="cocktailrezepte/moskito.php">Moskito</a></td>
    <td> ✰ ✰ </td>
    <td> Nein! </td>
    </tr>
    <tr>
    <td> <a href="cocktailrezepte/pinacolada.php">Pina Colada </a></td>
    <td> ✰ ✰ ✰</td>
    <td> Ja! </td>
    </tr>
    <tr>
    <td> <a href="cocktailrezepte/safersex.php">Safer Sex</a></td>
    <td> ✰ ✰</td>
    <td> Nein! </td>
    </tr>
    <tr>
    <td> <a href="cocktailrezepte/sexonthebeach.php">Sex on the Beach </a></td>
    <td> ✰ ✰ ✰</td>
    <td> Ja! </td>
    </tr>
    <tr>
    <td> <a href="cocktailrezepte/swimmingpool.php">Swimmingpool</a></td>
    <td> ✰ ✰ ✰ ✰ ✰</td>
    <td> Ja! </td>
    </tr>
    <tr>
    <td> <a href="cocktailrezepte/tequilasunrise.php">Tequila Sunrise </a></td>
    <td> ✰ ✰ ✰</td>
    <td> Ja! </td>
    </tr>
    <tr>
    <td> <a href="cocktailrezepte/virgincolada.php">Virgin Colada</a></td>
    <td> ✰ </td>
    <td> Nein! </td>
    </tr>
    <tr>
    <td> <a href="cocktailrezepte/zombie.php">Zombie </a></td>
    <td> ✰ ✰ ✰ ✰ ✰ </td>
    <td> Ja! </td>
    </tr>
    </table>

    </section>
    <?php include("includes/footer.php");?>

    Vllt weiß ja jemand, wie ich das ändern kann!

  • #2
    Hi,

    vorab: statt

    PHP-Code:
    if(isset ($_POST['Geschmack']) AND $_POST['Geschmack']=="11"
    usw.

    könntest du auch einmal mit is_numeric($_POST["geschmack"]) in nur einer(!) If-Abfrage abprüfen und als maskierte Variable in dein SQL Statement als Bedingung einfügen. Da musst du nicht auf jeden einzelnen Wert prüfen.

    Bitte nutze die PHP Tags hier im WYSIWYG Editor um den code lesbar darzustellen.

    Zur Zeit bleibt die Tabelle noch auf der Seite und über der Tabelle kommt eine weitere Tabelle mit den Ausgaben.
    Ist das die Frage? Wenn du deine Auswahl darstellen möchtest, musst Du sie auch entsprechend ausgeben.


    mfg Wolf29
    while (!asleep()) sheep++;

    Unterschätze nie jemanden der einen Schritt zurück geht! Er könnte Anlauf nehmen.

    Kommentar


    • #3
      PHP-Code:
      <?php include("includes/header.php");?>
      <body>
      <h1>Die 20 besten Cocktailrezepte</h1>
      <article>
      <header>
      <p>Nun geht's los: Verschaff dir einen Überblick über unsere fantastische und einzigartige Cocktailauswahl! Ein Klick auf den Cocktail bringt dich deinem Partyabend einen Schritt näher.</p>
      </header>
      <?php include("includes/nav.php");?>
      <section>
      <img src="bilder/bar.jpg" width="350" height="180" alt="Bildbar">
      <img src="bilder/haengematte.jpg" width="350" height="180" alt="Bildhängematte">
      <img src="bilder/kiwi.jpg" width="350" height="180" alt="Bildkiwi">
      <h3>Cocktailtabelle</h3>
      <form action="" method="post" name="register">
      Wähle deinen Geschmack aus und finde heraus, welche Cocktails für dich passen! Anschließend kannst du in der Tabelle auf deinen Cocktail klicken und das Rezept öffnen!<br/><br/>
      Geschmacksrichtung:
      <select name="Geschmack" size="1">
      <option value="0"> Wähle deinen Geschmack! </option>
      <option value="1"> scharf</option>
      <option value="2"> aromatisch </option>
      <option value="3"> würzig </option>
      <option value="4"> süß </option>
      <option value="5"> sauer </option>
      <option value="6"> erfrischend</option>
      <option value="7"> sahnig </option>
      <option value="8"> fruchtig </option>
      <option value="9"> herb </option>
      <option value="10"> prickelnd </option>
      <option value="11"> cremig </option>
      </select>
      <input type="submit" value="Filter anwenden" /></form>
      <br/>
      <?php
      include_once 'includes/DBManager.php';
      $dbm=new DBManager();

      //Geschmack
      if(isset ($_POST['Geschmack']) AND $_POST['Geschmack']=="1")
      {
      $sql"SELECT `Name`, Beschreibung, Alkoholgehalt
      FROM `Cocktail`
      INNER JOIN Cocktail_has_Geschmacksrichtung
      ON Cocktail.idCocktail = Cocktail_has_Geschmacksrichtung.Cocktail_idCocktai l
      WHERE Geschmacksrichtung_idGeschmacksrichtung = 1"
      ;
      $dbm->datenausgabeSimple($sql);
      }

      if(isset (
      $_POST['Geschmack']) AND $_POST['Geschmack']=="2")
      {
      $sql"SELECT `Name`, Beschreibung, Alkoholgehalt
      FROM `Cocktail`
      INNER JOIN Cocktail_has_Geschmacksrichtung
      ON Cocktail.idCocktail = Cocktail_has_Geschmacksrichtung.Cocktail_idCocktai l
      WHERE Geschmacksrichtung_idGeschmacksrichtung = 2"
      ;
      $dbm->datenausgabeSimple($sql);
      }

      if(isset (
      $_POST['Geschmack']) AND $_POST['Geschmack']=="3")
      {
      $sql"SELECT `Name`, Beschreibung, Alkoholgehalt
      FROM `Cocktail`
      INNER JOIN Cocktail_has_Geschmacksrichtung
      ON Cocktail.idCocktail = Cocktail_has_Geschmacksrichtung.Cocktail_idCocktai l
      WHERE Geschmacksrichtung_idGeschmacksrichtung = 3"
      ;
      $dbm->datenausgabeSimple($sql);
      }

      if(isset (
      $_POST['Geschmack']) AND $_POST['Geschmack']=="4")
      {
      $sql"SELECT `Name`, Beschreibung, Alkoholgehalt
      FROM `Cocktail`
      INNER JOIN Cocktail_has_Geschmacksrichtung
      ON Cocktail.idCocktail = Cocktail_has_Geschmacksrichtung.Cocktail_idCocktai l
      WHERE Geschmacksrichtung_idGeschmacksrichtung = 4"
      ;
      $dbm->datenausgabeSimple($sql);
      }

      if(isset (
      $_POST['Geschmack']) AND $_POST['Geschmack']=="5")
      {
      $sql"SELECT `Name`, Beschreibung, Alkoholgehalt
      FROM `Cocktail`
      INNER JOIN Cocktail_has_Geschmacksrichtung
      ON Cocktail.idCocktail = Cocktail_has_Geschmacksrichtung.Cocktail_idCocktai l
      WHERE Geschmacksrichtung_idGeschmacksrichtung = 5"
      ;
      $dbm->datenausgabeSimple($sql);
      }

      if(isset (
      $_POST['Geschmack']) AND $_POST['Geschmack']=="6")
      {
      $sql"SELECT `Name`, Beschreibung, Alkoholgehalt
      FROM `Cocktail`
      INNER JOIN Cocktail_has_Geschmacksrichtung
      ON Cocktail.idCocktail = Cocktail_has_Geschmacksrichtung.Cocktail_idCocktai l
      WHERE Geschmacksrichtung_idGeschmacksrichtung = 6"
      ;
      $dbm->datenausgabeSimple($sql);
      }

      if(isset (
      $_POST['Geschmack']) AND $_POST['Geschmack']=="7")
      {
      $sql"SELECT `Name`, Beschreibung, Alkoholgehalt
      FROM `Cocktail`
      INNER JOIN Cocktail_has_Geschmacksrichtung
      ON Cocktail.idCocktail = Cocktail_has_Geschmacksrichtung.Cocktail_idCocktai l
      WHERE Geschmacksrichtung_idGeschmacksrichtung = 7"
      ;
      $dbm->datenausgabeSimple($sql);
      }

      if(isset (
      $_POST['Geschmack']) AND $_POST['Geschmack']=="8")
      {
      $sql"SELECT `Name`, Beschreibung, Alkoholgehalt
      FROM `Cocktail`
      INNER JOIN Cocktail_has_Geschmacksrichtung
      ON Cocktail.idCocktail = Cocktail_has_Geschmacksrichtung.Cocktail_idCocktai l
      WHERE Geschmacksrichtung_idGeschmacksrichtung = 8"
      ;
      $dbm->datenausgabeSimple($sql);
      }

      if(isset (
      $_POST['Geschmack']) AND $_POST['Geschmack']=="9")
      {
      $sql"SELECT `Name`, Beschreibung, Alkoholgehalt
      FROM `Cocktail`
      INNER JOIN Cocktail_has_Geschmacksrichtung
      ON Cocktail.idCocktail = Cocktail_has_Geschmacksrichtung.Cocktail_idCocktai l
      WHERE Geschmacksrichtung_idGeschmacksrichtung = 9"
      ;
      $dbm->datenausgabeSimple($sql);
      }

      if(isset (
      $_POST['Geschmack']) AND $_POST['Geschmack']=="10")
      {
      $sql"SELECT `Name`, Beschreibung, Alkoholgehalt
      FROM `Cocktail`
      INNER JOIN Cocktail_has_Geschmacksrichtung
      ON Cocktail.idCocktail = Cocktail_has_Geschmacksrichtung.Cocktail_idCocktai l
      WHERE Geschmacksrichtung_idGeschmacksrichtung = 10"
      ;
      $dbm->datenausgabeSimple($sql);
      }

      if(isset (
      $_POST['Geschmack']) AND $_POST['Geschmack']=="11")
      {
      $sql"SELECT `Name`, Beschreibung, Alkoholgehalt
      FROM `Cocktail`
      INNER JOIN Cocktail_has_Geschmacksrichtung
      ON Cocktail.idCocktail = Cocktail_has_Geschmacksrichtung.Cocktail_idCocktai l
      WHERE Geschmacksrichtung_idGeschmacksrichtung = 11"
      ;
      $dbm->datenausgabeSimple($sql);
      }
      ?>
      <table>
      <table border="1">
      <caption> Cocktailrezepte </caption>
      <tr>
      <th> Bezeichnung </th>
      <th> Schwierigkeitsgrad </th>
      <th> Alkohol? </th>
      </tr>
      <tr>
      <td> <a href="cocktailrezepte/bloodymary.php">Bloody Mary </a></td>
      <td>✰ ✰ ✰ ✰</td>
      <td> Ja! </td>
      </tr>
      <tr>
      <td> <a href="cocktailrezepte/caipirinha.php">Caipirinha </a> </td>
      <td> ✰ ✰</td>
      <td> Ja! </td>
      </tr>
      <tr>
      <td> <a href="cocktailrezepte/cinderella.php">Cinderella</a></td>
      <td> ✰ ✰ </td>
      <td> Nein! </td>
      </tr>
      <tr>
      <td> <a href="cocktailrezepte/cosmopolitan.php">Cosmopolitan </a></td>
      <td> ✰ ✰ ✰ ✰ ✰ </td>
      <td> Ja! </td>
      </tr>
      <tr>
      <td> <a href="cocktailrezepte/cubalibre.php">Cuba Libre </a></td>
      <td> ✰ ✰ ✰</td>
      <td> Ja! </td>
      </tr>
      <tr>
      <td> <a href="cocktailrezepte/hurricane.php">Hurricane</a></td>
      <td> ✰ ✰ ✰ ✰</td>
      <td> Ja! </td>
      </tr>
      <tr>
      <td> <a href="cocktailrezepte/ipanema.php">Ipanema </a></td>
      <td> ✰ </td>
      <td> Nein! </td>
      </tr>
      <tr>
      <td> <a href="cocktailrezepte/longislandicetea.php">Long Island Icetea</a></td>
      <td> ✰ ✰ ✰ ✰ </td>
      <td> Ja! </td>
      </tr>
      <tr>
      <td> <a href="cocktailrezepte/maitai.php">Mai-Tai </a></td>
      <td> ✰ ✰ ✰</td>
      <td> Ja! </td>
      </tr>
      <tr>
      <td> <a href="cocktailrezepte/malibubeach.php">Malibu Beach</a></td>
      <td> ✰</td>
      <td> Ja! </td>
      </tr>
      <tr>
      <td> <a href="cocktailrezepte/margarita.php">Margarita </a></td>
      <td> ✰ ✰ ✰ ✰ ✰</td>
      <td> Ja! </td>
      </tr>
      <tr>
      <td> <a href="cocktailrezepte/mojito.php">Mojito </a></td>
      <td> ✰ ✰ ✰ </td>
      <td> Ja! </td>
      </tr>
      <tr>
      <td> <a href="cocktailrezepte/moskito.php">Moskito</a></td>
      <td> ✰ ✰ </td>
      <td> Nein! </td>
      </tr>
      <tr>
      <td> <a href="cocktailrezepte/pinacolada.php">Pina Colada </a></td>
      <td> ✰ ✰ ✰</td>
      <td> Ja! </td>
      </tr>
      <tr>
      <td> <a href="cocktailrezepte/safersex.php">Safer Sex</a></td>
      <td> ✰ ✰</td>
      <td> Nein! </td>
      </tr>
      <tr>
      <td> <a href="cocktailrezepte/sexonthebeach.php">Sex on the Beach </a></td>
      <td> ✰ ✰ ✰</td>
      <td> Ja! </td>
      </tr>
      <tr>
      <td> <a href="cocktailrezepte/swimmingpool.php">Swimmingpool</a></td>
      <td> ✰ ✰ ✰ ✰ ✰</td>
      <td> Ja! </td>
      </tr>
      <tr>
      <td> <a href="cocktailrezepte/tequilasunrise.php">Tequila Sunrise </a></td>
      <td> ✰ ✰ ✰</td>
      <td> Ja! </td>
      </tr>
      <tr>
      <td> <a href="cocktailrezepte/virgincolada.php">Virgin Colada</a></td>
      <td> ✰ </td>
      <td> Nein! </td>
      </tr>
      <tr>
      <td> <a href="cocktailrezepte/zombie.php">Zombie </a></td>
      <td> ✰ ✰ ✰ ✰ ✰ </td>
      <td> Ja! </td>
      </tr>
      </table>

      </section>
      <?php include("includes/footer.php");?>
      Okay, und wie gebe ich das aus? Also wie müsste so ein Echo-Befehl aussehen?

      Kommentar


      • #4
        Hi,

        einfaches Beispiel:

        PHP-Code:
        if(isset ($_POST['Geschmack']) AND is_numeric($_POST['Geschmack']))
        {
        // kenne deine Function 'datenausgabeSimple' nicht, aber
        // auf jedenfall den POST Parameter maskieren, bevor du
        // ihn so in das Statement einsetzt und verwendest
        $sql"SELECT `Name`, Beschreibung, Alkoholgehalt
        FROM `Cocktail`
        INNER JOIN Cocktail_has_Geschmacksrichtung
        ON Cocktail.idCocktail = Cocktail_has_Geschmacksrichtung.Cocktail_idCocktai l
        WHERE Geschmacksrichtung_idGeschmacksrichtung = '"
        .$_POST['Geschmack']."'";
        $dbm->datenausgabeSimple($sql);

        Dadurch sparst du dir die ganzen weiteren if Prüfungen!

        Jetzt lässt du dir mittels einer While Schleife die Werte z.B. in einer Tabelle ausgeben. Ich hoffe mal, dass du mysqli oder PDO verwendest?!

        mfg Wolf29
        while (!asleep()) sheep++;

        Unterschätze nie jemanden der einen Schritt zurück geht! Er könnte Anlauf nehmen.

        Kommentar


        • #5
          Danke Wolf29,

          wir verwenden PHP, MySQL und HTML. Trotzdem verstehe ich nicht so ganz, wie so eine while schleife aussehen sollte..

          Kommentar


          • #6
            Aktualisiere mal dein Script oben mit dem was Wolf29 vorgeschlagen hat, dann schauen wir weiter. Das verstößt derzeit ja schlimmstens gegen das DRY-Prinzip.

            Und dann schaut euch bitte auch das EVA-Prinzip an, das ist alles nicht so schön derzeit.

            wie so eine while schleife aussehen sollte
            Kommt u.a. auch darauf an, was $dbm->datenausgabeSimple($sql) zurückgibt.

            LG
            The string "()()" is not palindrom but the String "())(" is.

            Debugging: Finde DEINE Fehler selbst! | Gegen Probleme beim E-Mail-Versand | Sicheres Passwort-Hashing | Includes niemals ohne __DIR__
            PHP.de Wissenssammlung | Kein Support per PN

            Kommentar

            Lädt...
            X