Re: inserting data into columns and rows in php.
| From: | Meir Kriheli - MKsoft | Date: | Wed, 26 Jul 2000 12:42:56 +0000 |
| Subject: | Re: inserting data into columns and rows in php. | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-8266@lists.php.net to get a copy of this message | ||
Check this snippet :
<TABLE>
<?
$rowCount = 0;
$numberOfCols = 2;
while ( <fetch row from your database> ) {
if ( ($rowCount % $numberOfCols)==0) echo " <TR>\n";
echo ' <TD>' . <what ever you got from the database>
."</TD>\n";
if ( ($rowCount % $numberOfCols)==0) echo " </TR>\n";
$rowCount++;
}
?>
</TABLE>
Comments :
* the spaces and the \n charetes before and after the <TR> <TD> etc. are
for better readability of source (if you view the source of the output page
in the browser).
You should try to work that way for easier debugging of output pages.
* The script is written that way for easier reading. you could make some
shortcuts, but I wanted it be readable. Instead of the $numberOfCols you
could
substitute it with the number itself. The script here is generic so it would
much
both Maniac's and your ColCount.
HTH
Meir Kriheli
MKsoft computer systems
'There's someone in my head but it's not me" - Pink Floyd
----- Original Message -----
> Maniac,
>
> I think what you're trying to do is quite similar to
> what i have been trying to do. Only, i wanted hust two
> cells in each row. The rows to be generated
> automatically according to the number of records in
> the database. I have tried practically all the answers
> that were posted for your questiob but none of them
> had worked for me. Surprisingly, i never got a single
> reply posted to my problem while u got so many :(
>
> Anyway, if u do find some way out, i'd appreciate u
> helping me.
>
> thanx,
> T. Edison jr.
>