View Full Version : Split Search results into columns
e1seix
07-15-2007, 09:34 PM
For example, if i were to call a search from mysql database that's particularly long, what php code could i use to split the results into, say, three separate columns within a single table, without repetition ie. i don't want the "if" statement to just repeat itself three times
Hmm...
<table>
<tr>
<?php for($i = 0; $row = mysql_fetch_array($rs); ++$i) { ?>
<?php if($i % 3 === 0) { ?>
</tr>
<tr>
<?php } ?>
<td>
<?php echo($row['data']); ?>
</td>
<?php } ?>
</tr>
</table>You get an extra row at the beginning and end of the table, but it's as neat as I can make it, I think. You could, of course, take care of the extra rows with another two if blocks.
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.