Posted by J.O. Aho on 01/09/07 12:58
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
Navigation:
[Reply to this message]
|