Re: formating output
| From: | Tatang Widyanto | Date: | Sat, 18 Dec 2004 04:02:44 +0000 |
| Subject: | Re: formating output | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-204644@lists.php.net to get a copy of this message | ||
print "<table>\n";
print "<tr>\n";
$counter = 0;
while ($result = mysql_fetch_array($pointer)) {
$counter++;
if ($counter % 4 === 0) {
print "<td>".$result[1]."</td>\n";
print "</tr>\n";
print "<tr>\n";
} else {
print "<td>".$result[1]."</td>\n";
}
}
// add blank cells if number of cell on last row isn'4 four.
for ($i = 0; $i < $counter % 4; $i++) {
print "<td> </td>\n";} print "</tr>\n"; print "</table>\n"; --------------------------------- Larry L wrote:
I'm sure this is easy and I'll feel silly when I see how it's done,
but, my mnd is a blank,
this structure prints out a table with a new row for each item
<table >
<?
While ( $results = mysql_fetch_array($pointer)) {
print "<tr><td ><$results[1] </td></tr>" ;
}
?>
</table>
what I want to do is print out a table 4 columns wide and however many rows
high needed to run through the data
HOW do I loop through the array and get <td>data</td> printed 4 times
then a new row started and then 4 more <td> cells printed, etc
thank you in advance