Jump to content

Displaying Database entries in table cells


dabigchz

Recommended Posts

Basically, I'd like to display each entry in my database in a table cell (a picture and name), but I can't figure out how to start a new row.

 

My current code:

while ($row = mysql_fetch_array($result)) {

echo "<td align='center' width='90'>";
echo "Stuff inside table cell";
echo "</td>";

}

 

What I'd like to do is insert a </tr><tr> after every 6th entry, to have a nice neat table. Any help would be greatly appreciated :)

$x=0;
while ($row = mysql_fetch_array($result)) {
    echo "<td align='center' width='90'>";
    echo "Stuff inside table cell";
    echo "</td>";

    $x++;

    if($x==5)
    {
       echo(PHP_EOL."</tr>".PHP_EOL."<tr>".PHP_EOL)
       $x=0;
    }
}

 

that should do it

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.