Reply to Re: simple loop? help

Your name:

Reply:


Posted by meltedown on 10/24/30 11:34

Bob Bedford wrote:
> I do probably need a good coffee, but I can't find out a simple way to
> do so.
>
> Let's say I want to create a table using a number I receive.
> For every number, I must have a table with maximum 5 columns.
>
> Example:
> 10 will gives 2 rows of 5 columns
> 12 will gives 2 rows of 5 columns and a row of 2 columns.
> ....
>
> The problem is that I've to keep the value of every cell like this for 12
> 1 2 3 4 5
> 6 7 8 9 10
> 11 12
>
> How to do so ?
> I've done this so far:
> $columns = 10;
> $lines = $columns / 5;
>
> for($K=0;$K<=($lines+1);$K++)
> <?php for($K=0;$K<=($lines+1);$K++){?>
> <tr>
> <?php
> for($I=1;$I<=($columns-($K*5));$I++)
> echo('<td align="center">Colonne '.($K*5+$I).'</td>');
> ?>
> </tr>
>
> But It doesn't work properly. I can't figure out a simple way.
>
> Thanks for helping.
>
> Bob
>
I wouldn't use tables for this, I would use divs.
example:http://www.reenie.org/test/test21.php


<?
include "../../lib/geolib.php";
$s="
.cell{width:16%; margin:1px;float:left;border:solid 1px; padding:2px;}
h4{margin:0; padding:1em 0 0 0; clear:both;}
";

$t="5 cell css table";

$num=8;
$p.=h4("number of cells is $num");
for($i=0; $i<$num; $i++)
$p.=div("Colonne $num",NULL,'cell');

$num=12;
$p.=h4("number of cells is $num");
for($i=0; $i<$num; $i++)
$p.=div("Colonne $num",NULL,'cell');

echo html($p, head($t,NULL,$s));
?>

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация