Formatting MySQL 1 column query output to 2 html columns

From: Date: Sun, 11 Jun 2000 20:06:00 +0000
Subject: Formatting MySQL 1 column query output to 2 html columns
Groups: php.general 
Request: Send a blank email to php-general+get-1568@lists.php.net to get a copy of this message
Dear PHP Coders, I'm trying to format my mysql query (1 column of information) into a two column html table, example: <table> <tr><td>1001</td><td>1002</td></tr> <tr><td>1003</td><td>1004</td></tr> </table> The only thing I'm getting now is just two columns of the same information, example: <tr><td colspan=2>10019</td><td>colspan=2>10019</td></tr> I would really appreciate some help. <---Start Code----> <html> <body> <table border=1> <?php $host = "localhost"; $user = "username"; $pass = "password"; $db = mysql_connect($host,$user,$pass); mysql_select_db("db18261a",$db); $result = mysql_query("select model from cfs",$db); $myrow = mysql_fetch_array($result); $number_cols ="2"; for ($i=0;$i<intval(mysql_numrows($result)/$number_cols)+1;$i++){ while ($myrow = mysql_fetch_array($result)) { echo "<tr>\n"; for ($j=0;$j<$number_cols;$j++){ echo '<td colspan=2>'; echo "$myrow[model]</td>"; } echo "</tr>\n"; } } php?> <--End Code--> -Jeremy k_mayo@yahoo.com __________________________________________________ Do You Yahoo!? Yahoo! Photos -- now, 100 FREE prints! http://photos.yahoo.com

« previous php.general (#1568) next »