PHP Forum

PHP Forum (http://www.selfphp.de/forum/index.php)
-   PHP Grundlagen (http://www.selfphp.de/forum/forumdisplay.php?f=12)
-   -   bestimmte html ausgabe (http://www.selfphp.de/forum/showthread.php?t=9081)

joker 15.11.2004 20:03:04

bestimmte html ausgabe
 
hallo, ich versuche bestimmte daten auszugeben aber dabei soll jede 2te ausgabe rechts sein, also so in etwa:
Code:

<table>
  <tr>
    <td>
      <table>
        <tr>
          <td>ausgabe 1</td>
        </tr>
        <tr>
          <td>ausgabe 3</td>
        </tr>
        <tr>
          <td>ausgabe 5</td>
        </tr>
      </table>
    </td>
    <td>
      <table>
        <tr>
          <td>ausgabe 2</td>
        </tr>
        <tr>
          <td>ausgabe 4</td>
        </tr>
        <tr>
          <td>ausgabe 6</td>
        </tr>
      </table>
    </td>
  </tr>
</table>

wobei die anzahl der ausgabe nicht feststeht und das ganze per query mit ner while schleife aus der db gehohlt wird...

meine idee wäre ein counter immer hochzuzählen:
Code:

while () {
counter++
if counter 1 -> mach ausgabe links
else
reset counter 0 & mach ausgabe rechts

}

aber wie mach ich das mit den html elementen?
also immer alles über und unter <tr><td>ausgabe x</td></tr> steht

wurde mich freuen wenn jemmand ne lösung hätte wie ich das anstelle...

Yzerman 15.11.2004 21:19:08

PHP-Code:

echo '<table width="100%" cellpadding="2" cellspacing="2">';
$counter 0;
while(....)
{
   if((
$counter%2)==0)
   {
      echo 
'<tr><td>' $datensatz '</td>';
   }
   else
   {
      echo 
'<td>' $datensatz '</td></tr>';
   }
   
$counter++;
}
if((
$counter%2)==1)
{
   echo 
'<td>&nbsp;</td></tr>';
}
echo 
'</table>'

So etwa?

joker 15.11.2004 21:37:56

danke geht, wie kom ich bloß auf 2 tabellen ;)


Alle Zeitangaben in WEZ +2. Es ist jetzt 13:15:10 Uhr.

Powered by vBulletin® Version 3.8.3 (Deutsch)
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.