Re: Displaying Records

From: Date: Mon, 21 Aug 2000 21:31:34 +0000
Subject: Re: Displaying Records
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-12831@lists.php.net to get a copy of this message
How about this way: $n=1; echo '<tr>'; while ($row = mysql_fetch_row($result) { echo "<td>$row[0]</td>"; if (($n % 3)==0) echo '</tr><tr>'; $n++; } echo '</tr> -- Meir Kriheli MKsoft computer systems "There's someone in my head but it's not me" - Pink Floyd On Mon, 21 Aug 2000, peter tatischev wrote: > > I am pulling records for a MySQl database. > > Simply displaying them using a Do while statement. > > > > However what I would like to to display three records horizontally in > > a table then drop down to a new table row and display the next three > > records, etc until all the records are displayed. > > > > How do I do this. > > i'd do this like: > $n=1; > while ($row = mysql_fetch_row($result) > { > if ($n==1) echo "<tr>"; > echo "<td>$row[0]</td>; > if ($n==3) > { > echo "</tr>"; > $n=1; > } > $n++; > } > I'm sure there is a more elgant solution, but that's just the simplest > that comes up to me...

« previous php.general (#12831) next »