Re: Formatting MySQL 1 column query output to 2 html columns
| From: | Jaroslav Kazmir | Date: | Sun, 11 Jun 2000 22:38:47 +0000 |
| Subject: | Re: Formatting MySQL 1 column query output to 2 html columns | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-1571@lists.php.net to get a copy of this message | ||
> 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>
>
TRY this :-)
echo "<TABLE>\n";
$num = 0;
while ($array = mysql_fetch_array($result)) {
if ($num % 2 == 0)
echo "<TR>\n";
echo "<TD>".$array["your_number"]."</TD>\n";
if ($num % 2 == 0)
echo "</TR>\n";
$num++;
}
echo "</TABLE>\n";
for tree cols you could try ($num % 3 == 0)
% ... this is mod (6 % 3 = 0
7 % 3 = 1
8 % 3 = 2
9 % 3 = 0 etc.)
I hope in a good result
Nice day, bye
Jarda