RE: [PHP-GENERAL] Formatting MySQL 1 column query output to 2 html columns

From: Date: Sun, 11 Jun 2000 21:50:23 +0000
Subject: RE: [PHP-GENERAL] Formatting MySQL 1 column query output to 2 html columns
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-1570@lists.php.net to get a copy of this message
> $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"; > } > > } Replace the above with this: while($myrow = mysql_fetch_array($result)){ echo '<TR>'."\n"; echo ' <TD>'.$myrow['model'].'</TD>'."\n"; if($myrow = mysql_fetch_array($result)){ echo ' <TD>'.$myrow['model'].'</TD>'."\n"; echo '</TR>'."\n\n"; }else{ echo '</TR>'."\n\n"; } } HTH -- Richard Heyes http://www.heyes-computing.net/scripts/

« previous php.general (#1570) next »