[thelist] PHP/MySQL results in multiple table cells?

Jeremy Ashcraft ashcraft at 13monkeys.com
Fri Sep 28 11:11:42 CDT 2001


I'll expand a bit on Michael's code to fit your needs

<tr>
<?php
     $newData=array(); // this is where the data will be stored

     mysql_connect("localhost");
     $query="select thumb from images";
     $result=mysql_db_query("cdcollection",$query);
     $num_rows=mysql_num_rows($result);
 
     for ($i=1; $i<=$num_rows; $i++) {
 	$newData[]=mysql_fetch_array($result);
	echo "<td>".$newData[0]."</td>\n";
	if(($i % 3) == 0) {
		echo "</tr>\n<tr>\n";
	}
     }
?>
</tr>

or something to that effect.
pretty much just looping through the results and every 3rd result, starting a 
new table row. 

jeremy




More information about the thelist mailing list