Re: multiple outputs to mysql_query()
| From: | zerosumzero@yahoo.com | Date: | Sun, 08 Jul 2001 08:00:25 +0000 |
| Subject: | Re: multiple outputs to mysql_query() | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-56731@lists.php.net to get a copy of this message | ||
on 7/8/01 3:39 AM, Adam at adam@wangallery.com wrote:
> i want my mysql query result to output 2 mysql output rows for every <tr>
> set. I'm used to just doing a do/while statement for a single mysql output
> per row.
I'd do this:
<?php
echo '<table>';
$result = mysql_query("SELECT * from table WHERE type='default'");
$numrows = mysql_num_rows ($result);
while ($numrows) {
$row = mysql_fetch_row ($result);
echo "<tr>\n<td>$row[0]</td>\n";
$row = mysql_fetch_row ($result);
echo "<td>$row[0]</td>\n</tr>";
$numrows = ($numrows - 2);
}
echo '</table>';
?>