Benötige Hilfe

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Benötige Hilfe

    PHP Code:
    $max 4// Test
    $result $db->query("SELECT * FROM ... LIMIT $max");
    while(
    $row $db->fetch_array($result)) {
        
    $bg_color $row['bg_color'];
        
    $fontcolor $row['fontcolor'];    
        
    $xtext $row['xtext'];
        eval(
    "\$tpl->output(\"".$tpl->get("testbit")."\");");
    }
    // end while 
    Hallo,

    ich möchte gerne verschiedene in der MySQL gespeicherte Texte in verschiednen Tabellen ausgeben. Wie macht man das?

    Die Ausgabe in "testbit" ist erst mal egal:
    echo "
    <table><tr>
    <td>$xtext1</td><td>$xtext2</td>...
    </tr></table>
    ";

  • #2
    PHP Code:
    ...
    echo 
    "<table>\n\t<tr>\n";
    while (...)
       echo 
    "\t\t<td>".$row['xtext']."</td>\n";
    echo 
    "\t</tr>\n</table>\n";
    ... 

    Comment


    • #3
      Danke, und soooo schnell.

      Kann ich noch eine Frage drauflegen

      Wie mache ich das, wenn ich die Ausgaben auch so in Tabellen in mehreren Zeilen haben muss?
      Ich merke gerade, dass das doch sehr in die Breite gehen kann

      $xtext1 $xtext2 $xtext3 $xtext4
      $xtext5 $xtext6 $xtext7 $xtext8

      Eine if()-Schleife in der while()-Schleife vielleicht?
      PHP Code:
      if($i 3) { 
         </
      tr>...<tr>... 
         
      $i 0;
      }
      $i++; 
      Oder ist es besser dies mit in die while(... && $i < 4)-Schleife zu schreiben?

      Comment


      • #4
        Du willst max 3 Zellen pro Zeile
        PHP Code:
        $i 1;
        echo 
        "<table>\n\t<tr>\n";
        while (...)
           if(
        $i != 0){
               echo 
        "\t\t<td>".$row['xtext']."</td>\n";
           }
           else{
               echo 
        "\t\t<td>".$row['xtext']."</td>\n</tr>";
          }
        echo 
        "</table>\n";

        Gruss

        tobi
        Gutes Tutorial | PHP Manual | MySql Manual | PHP FAQ | Apache | Suchfunktion für eigene Seiten

        [color=red]"An error does not become truth by reason of multiplied propagation, nor does truth become error because nobody sees it."[/color]
        Mohandas Karamchand Gandhi (Mahatma Gandhi) (Source)

        Comment


        • #5
          Auch dir besten Dank für die Hilfe.
          Ja, 3 Zellen pro Zeile.
          Aber so klappt das leider nicht.

          Ich bekomme damit
          1x eine Zelle in der ersten Zeile und dann folgen alle weiteren einfach so.

          01:40 Uhr, jetzt muss ich aber mal eine Runde schlafen, puh

          Comment


          • #6
            Uuups sorry. Probier das mal
            PHP Code:
            $i 1;
            $ende 'anzahl_zu_machender_einträge';
            echo 
            "<table>\n\t<tr>\n";
            while (
            $i <= $ende){
               if(
            $i != 0){
                   echo 
            "\t\t<td>".$row['xtext']."</td>\n";
               }
               elseif(
            $i === && ($i 1) < $ende){
                   echo 
            "\t\t<td>".$row['xtext']."</td>\n</tr><tr>";
              }
               else{
                   echo 
            "\t\t<td>".$row['xtext']."</td>";
              }
               
            $i += 1;
            }
            echo 
            "</tr></table>\n"
            Man muss die neue Zeile auch "öffnen". Sorry da war ich wohl ein wenig müde. Auch sollte der Zähler natürlich erhöht werden.

            Gruss

            tobi
            Last edited by jahlives; 16-12-2005, 04:01.
            Gutes Tutorial | PHP Manual | MySql Manual | PHP FAQ | Apache | Suchfunktion für eigene Seiten

            [color=red]"An error does not become truth by reason of multiplied propagation, nor does truth become error because nobody sees it."[/color]
            Mohandas Karamchand Gandhi (Mahatma Gandhi) (Source)

            Comment


            • #7
              Dankeschön!
              Jetzt hat es geklappt, ich hatte jedoch die $ende rausgenommen, weil ich das mit LIMIT bereits eigegrenzt hatte.

              Comment

              Working...
              X