Posted by linda on 01/11/07 13:55
"J.O. Aho" <user@example.net> wrote in message
news:50hhrhF1fuu8cU1@mid.individual.net...
> linda wrote:
>> Could some one point me to a link or explain how to show the pulled
>> records from a database in two columns?
>>
>> I would like to pull the field categories, and display them in two
>> columns in a table as follows:
>>
>>
>> TABLE NAME CATEGORIES
>>
>> CAT_ONE CAT_TWO
>> CAT_THREE CAT_FOUR
>>
>> and so on....
>
>
> echo "<table><tr><td>Column one</td><td>Column two</td>";
> $numbercolumns=2;
> $counter=0;
> while{$row=mysql_fetch_array($result)) {
> $counter++;
> if(($counter%$numbercolumns)==0) {
> echo "</tr><tr>";
> }
> echo "<td>".$row['column_name']."</td>";
> }
> while($counter%$numbercolumns) {
> $counter++;
> /* In case we don't have the right amount of items to make a full row */
> echo "<td> </td>";
> }
> echo "</tr><td>";
>
>
> Something like that could work, but I hope you get the idea and make
> something more useful.
>
> --
>
> //Aho
Thank you Aho for giving me an example of how to go about it. I'm going to
sit down at the weekend and have a go at this myself. I hope you don't
mind, but if I have any problems (questions), would it be ok if I came back
to you with them?
Best wishes,
Linda
[Back to original message]
|