[FX.php List] PHP Question

Gjermund Gusland Thorsen ggt667 at gmail.com
Fri Jul 21 02:35:16 MDT 2006


A think I see on this list is that alot of scripts would benefit in
readability by putting the php code in front of <html> -tag

Like I have done here:

<?
$cells=10; //the number of foundrecords
$curcells = $cells;
$rows = ceil( $cells / 3 );
$falsecells = $rows * 3;
$leftcells = $falsecells - $cells;
$currows = 0;
while( $currows < $rows && $cells-1 > $leftcells ) {
	$cell[] = '<td>This is a test</td>';
	$curcells = $curcells - 1;
	if( $cells - $curcells == 3) {
		$cell[] = '</tr><tr>';
		$cells = $curcells;
		$currows++;
	}
}
If( $cells > 0 ) {
	for( $num = 0; $num < $cells; $num++ ) {
		$cell[] = '<td>This is a test</td>';
	}
}
?><html>
<head><h1>Table Test</h1></head>
<body>
<table>
<tr>
<?echo implode( "\n", $cell );?>
</tr>
</table>
</body>
</html>

On 7/20/06, David Tinoco <davet15 at hotmail.com> wrote:
>
> Thanks for everyones suggestions. I also created my own, which I think works
> (I tested it several times and it seems to work fine.)
>  This example, however is pure PHP without the FX part. I guess I would
> switch the "This is a test" part with the FX variables.
>
> <html>
> <head><h1>Table Test</h1></head>
> <body>
> <table>
> <tr>
> <?php
>  $cells=10; //the number of foundrecords
> $curcells=$cells;
> $rows=ceil($cells/3);
> $falsecells=$rows*3;
> $leftcells=$falsecells-$cells;
> $currows=0;
> while($currows<$rows && $cells-1>$leftcells)
> {
> echo'<td>This is a test</td>';
> $curcells=$curcells-1;
> if($cells-$curcells==3)
>  {
>  echo'</tr><tr>';
>  $cells=$curcells;
>  $currows++;
>  }
> }
> If($cells>0)
> {
> for($num=0;$num<$cells;$num++)
> {
> echo'<td>This is a test</td>';
> }
> }
> ?>
> </tr>
> </table>
> </body>
> </html>
>
>
>
>
> ________________________________
> With MSN Spaces email straight to your blog. Upload jokes, photos and more.
> It's free! It's free!
>
> _______________________________________________
> FX.php_List mailing list
> FX.php_List at mail.iviking.org
> http://www.iviking.org/mailman/listinfo/fx.php_list
>
>
>


More information about the FX.php_List mailing list