Ausgabe der DB in eine Tabelle

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

  • #16
    Keine Ahnung?

    Auf jeden fall hab ich jetzt schon mal so:

    Max Mustermann 0
    Thomas Mustermann 0

    Wobei 0 für nicht aktiv steht. Wie bekomm ich jetzt hin, dass statt 0 eine checkbox ist?

    Der Code hat sich nicht verädnert, nur die select from anweisung

    Micronax

    Kommentar


    • #17
      Gibt doch noch ne kleine veränderung:

      PHP-Code:
      <?php
      /* Ausgabe der Ergebnisse in HTML */
      echo "<table width='90%' border='0' cellpadding='8' 
      class='tablestyle'>\n"
      ;
      echo 
      '<tr style="vertical-align: top">
        <td style="text-align: left"><b>Benutzername</b></td>
                          <td colspan="2"><b>Aktivieren</b></td>
      </tr>'
      ;
      while (
      $line mysql_fetch_array($resultMYSQL_ASSOC)) {
          echo 
      "\t<tr>\n";
          foreach (
      $line as $col_value) {
              echo 
      "\t\t<td>$col_value</td>\n";
          }
          echo 
      "\t</tr>\n";
      }
      echo 
      "</table>\n"?>
      Zuletzt geändert von ; 18.03.2006, 14:02.

      Kommentar


      • #18
        schau Dir mal an wie eine markierte Checkbox in html aussieht und
        dann was Du ausgibst.

        Kommentar


        • #19
          mir ist schon klar, wie ne markierte chekcbox in html ausieht..

          Aber wie bekomm ich die in die tabelle in jede 2. spalte?

          Hab auch noch die Steuerzeichen entfernt

          PHP-Code:
          <?php
          /* Ausgabe der Ergebnisse in HTML */
          echo "<table width='90%' border='0' cellpadding='8' 
          class='tablestyle'>"
          ;
          echo 
          '<tr style="vertical-align: top">
            <td style="text-align: left"><b>Benutzername</b></td>
                              <td colspan="2"><b>Aktivieren</b></td>
          </tr>'
          ;
          while (
          $line mysql_fetch_array($resultMYSQL_ASSOC)) {
              echo 
          "<tr>";
              foreach (
          $line as $col_value) {
                  echo 
          "<td>$col_value</td>";
              }
              echo 
          "</tr>";
          }
          echo 
          "</table>"?>
          Micronax
          Zuletzt geändert von ; 18.03.2006, 14:11.

          Kommentar


          • #20
            na - dann gib sie doch aus.

            Wie heißt denn der Befehl um html mit php auszugeben?

            Kommentar


            • #21
              LOL?

              ja echo '<input name="active" type="checkbox" id="active" />'

              Micronax

              Kommentar


              • #22
                nur das Probl ist ja:

                Wie bekomme ich die Checkbox dahin, wo sie hinsoll undzwar in jeder Zeile?

                Micronax

                Kommentar


                • #23
                  du gibst in der while-schleife die zeilen aus - da kommt auch die ausgabe der checkbox hin. ich verstehe nicht, wo das problem liegt.

                  Kommentar


                  • #24
                    Jetzt sieht es so aus:

                    PHP-Code:
                    <?php
                    /* Ausgabe der Ergebnisse in HTML */
                    echo "<table width='90%' border='0' cellpadding='8' 
                    class='tablestyle'>"
                    ;
                    echo 
                    '<tr style="vertical-align: top">
                      <td style="text-align: left"><b>Benutzername</b></td>
                                        <td colspan="2"><b>Aktivieren</b></td>
                    </tr>'
                    ;
                    while (
                    $line mysql_fetch_array($resultMYSQL_ASSOC)) {
                        echo 
                    "<tr>";
                        foreach (
                    $line as $col_value) {
                            echo 
                    "<td>$col_value</td>";
                        }
                        echo 
                    "<td><input name='active' type='checkbox' id='active' 
                    /></td>"
                    ;
                        echo 
                    "</tr>";

                    }
                    echo 
                    "</table>"?>
                    Aber wie bekomm ich jetzt die 0 in der zweitenspalte weg?

                    Micronax

                    Kommentar


                    • #25
                      überleg mal selbst - du gibst mit der foreach schleife jede spalte aus.
                      foreach heißt nicht umsonst so. wenn du eine spalte ausschließen möchtest, musst du eine if-abfrage einbauen, die in jedem zyklus kontrolliert, ob es sich um eine nicht-erwünschte spalte handelt.

                      Kommentar


                      • #26
                        Sieht jetztg so aus:

                        PHP-Code:
                        <?php
                        /* Ausgabe der Ergebnisse in HTML */
                        echo "<table width='90%' border='0' cellpadding='8' 
                        class='tablestyle'>"
                        ;
                        echo 
                        '<tr style="vertical-align: top">
                          <td style="text-align: left"><b>Benutzername</b></td>
                                            <td colspan="2"><b>Aktivieren</b></td>
                        </tr>'
                        ;
                        while (
                        $line mysql_fetch_array($resultMYSQL_ASSOC)) {
                            echo 
                        "<tr>";
                            foreach (
                        $line as $col_value) {
                                echo 
                        "<td>$col_value</td>";
                            }
                            echo 
                        "<td><input name='active' type='checkbox' 
                        id='
                        $username' /></td>";
                            echo 
                        "</tr>";

                        }
                        echo 
                        "</table>"?>
                        nur jetzt steht nur noch eine zeile in der <table> obwohl 2 in der Db stehen

                        Micronax

                        Kommentar


                        • #27
                          so siehst Du ja schon mal besser, was überhaupt abgeht:


                          PHP-Code:
                          while ($line mysql_fetch_array($resultMYSQL_ASSOC))
                              {
                              echo 
                          "<tr>";
                                    foreach (
                          $line as $col_value)
                                   {
                                   echo 
                          "<td>$col_value</td>";
                                   }
                              echo 
                          "<td><input name='active' type='checkbox' id='$username'/></td>";
                              echo 
                          "</tr>";

                              } 
                          in der foreach Schleife werden Deine Reihen erzeugt
                          und was steht da drin? die Ausgabe der checkbox?
                          die Ausgabe von $col_value?

                          Kommentar


                          • #28
                            Das ist mein aktuelle Script, nur es werden immer nur ein Benutzer angezeigt, obwohl es 3 gibt

                            PHP-Code:
                            <?php
                            /* Ausgabe der Ergebnisse in HTML */
                            echo "<table width='90%' border='0' cellpadding='8' 
                            class='tablestyle'>"
                            ;
                            echo 
                            '<tr style="vertical-align: top">
                              <td style="text-align: left"><b>Benutzername</b></td>
                                                <td colspan="2"><b>Aktivieren</b></td>
                            </tr>'
                            ;
                            while (
                            $line mysql_fetch_array($resultMYSQL_ASSOC)) {
                                echo 
                            "<tr>";
                                foreach (
                            $line as $col_value) {
                                    echo 
                            "<td>$col_value</td>";
                                    echo 
                            '<td><input name="active" type="checkbox" 
                            id="active" value="'
                            .$username.'"></td>';
                                }
                                echo 
                            "</tr>";

                            }
                            echo 
                            "</table>"?>
                            Micronax

                            Kommentar


                            • #29
                              dann hast nur einen user der die Bedingung in der sql-Abfrage erfüllt.

                              Kommentar


                              • #30
                                PHP-Code:
                                $query "SELECT 
                                    username
                                FROM 
                                    awaiting
                                WHERE
                                    active = '0'"
                                ;
                                $result mysql_query($query) or die("Anfrage fehlgeschlagen: " 
                                mysql_error());
                                $row mysql_fetch_array($result); 
                                Aber es gibt noch 2 benutzer wo active auf 0 steht.

                                Micronax

                                Kommentar

                                Lädt...
                                X