Re: dynamic table

From: Date: Wed, 26 May 2004 15:12:41 +0000
Subject: Re: dynamic table
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-186998@lists.php.net to get a copy of this message
> > >Hiya, > > > >How can i draw a new <tr> AFTER FIVE <td> in the following loop > > > >(i want to echo the records in 5 columns width tables whatever the number > of > >records will be fetched) > > > >.. > >echo '<table>'; > > > >while ($myrow = mysql_fetch_array($sql)) > >{ > >echo $myrow[0]; > >} > >echo '</table>'; > > > > > >regards > > $i = 1; > echo '<table border=1>' . "\n"; > echo '<tr>' . "\n"; > > while ($myrow = mysql_fetch_array($sql)){ > > echo '<td>' . $myrow[0]. "</td>\n"; > > if ($i % 5 == 0){ > echo "</tr>\n<tr>"; > } > > $i++; > } > > $odd = ($i - 1) % 5; > if ($odd){ > echo '<td colspan="'.$odd.'">&nbsp;</td>' . > "\n"; > } > echo '</tr>' . "\n"; > echo '</table>' . "\n"; > > > adrian sorry the $odd bit at the end aint right but you get the idea. adrian

« previous php.general (#186998) next »