Hi Sander,

> I made a database with bookmarks, these bookmarks are catogarized by
> type.
> Now I want to display those bookmarks in tables by category. This works
> already fine.
> The only problem I have is that the tables are very difficult to handle.
>
> I want to make 4 tables in a row (so that will be 4 dif categories with
> bookmarks) and after that, the next table should start under the first
> one.
> Like this
>
> category        category        category        category
> xxxxxxx         xxxxxxx        xxxxxxx         xxxxxxx
> xxxxxxx         xxxxxxx        xxxxxxx         xxxxxxx
> xxxxxxx         xxxxxxx        xxxxxxx         xxxxxxx
>
> category        category        category        category
> xxxxxxx         xxxxxxx        xxxxxxx         xxxxxxx
> xxxxxxx         xxxxxxx        xxxxxxx         xxxxxxx
> xxxxxxx         xxxxxxx        xxxxxxx         xxxxxxx
>
>
> (xxxxx = a weblink ;-)
>
> The (dutch)  website where you can find a full example for what I mean:
> http://www.startpagina.nl/

The description (above) shows category-columns of a regular/uniform length/height, so 
that the second set of
four category headings all appear on the same line. The web page example does not look 
like this, but the next
category starts immediately under the last entry of its columnar predecessor...

How are you retrieving the bookmarks from the database - all in one query, or a series 
of queries to retrieve a
category at a time? (I'll assume the former)

Here are two ways to implement in PHP (depending upon how you want to 'visualise' the 
data):
1 table - see the data as four columns
Set up a two-dimensional array in RAM, and by working through the db-resultset a row 
at a time populate the
table with column-row data by working down each column until the category changes and 
then shifting over one
column, etc, then print the table with two (nested) loops to output one row at a time 
across the columns until
all of the table data has been dealt with. (You could view the resultset as a 'buffer' 
and really get
complicated to 'save' RAM, but my advice would be to get the above working first, and 
then try any optimisation
ideas)
2 resultset
View the resultset as a single column of bookmarks (or read it into a single 
one-dimensional array), depending
upon your chosen db and PHP's retrieval mechanism you could set up four 'pointers' 
into the resultset - one for
each column, then read one result-row from each of the four pointers (incrementing as 
you go) to immediately
output within each of the four output columns.

Programmatically, it would be a lot easier to implement the flow the categories 
horizontally, eg
category         xxxxxxx         xxxxxxx        xxxxxxx
category         xxxxxxx         xxxxxxx        xxxxxxx         xxxxxxx
                     xxxxxxx         xxxxxxx
category         xxxxxxx         xxxxxxx        xxxxxxx         xxxxxxx

Enough to get you going?

Regards,
=dn



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to