Re: need help with a table please - sorry

From: Date: Wed, 12 Feb 2003 14:56:59 +0000
Subject: Re: need help with a table please - sorry
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-135311@lists.php.net to get a copy of this message
>----- Original Message ----- >From: "Denis L. Menezes" <menezesd@singnet.com.sg> >Sent: Wednesday, February 12, 2003 9:43 AM >Subject: [PHP] need help with a table please - sorry >Sorry I sent the wrong code in my last mail. Here is my correct code. >I want the output of my query to be formatted such that after every 7th >output, the 8th one should start on a new row in the table. I have written the >following code but does not work. Can someone please help? Untested, but I think will do what you want: <table width="800" border="0" cellspacing="0" cellpadding="3"> <tr> <?php $i=0; while($row=mysql_fetch_array($result)){ $i=$i+1; // if this is the 8th item in this row, end current row, & start another if (0 == ($i %8)){ Print "</tr>\n<tr>"; } Print"<td width=\"150\" >"; Print "<a href=\"findbycategory.php?"."CategoryId=".$row"CategoryId"] ."\"><font color=\"#000040\" size=\"2\">$row[CategoryName]</font></a>"." "; Print "</td>"; } // ?fill out last row if don't have 7 items? if (0 != ($i %8)){ ?> <td><div align="center">&nbsp;</div></td> <?php } ?> </tr> </table>

« previous php.general (#135311) next »