[thelist] ASP+SQL+HTML tables: is this the sensible way to query my db and display the data

Elfur Logadottir elfur at elfur.is
Fri Aug 17 18:57:06 CDT 2001


Fellow strugglers

I have a structural sql/asp question. It's not a problem - yet.
a similar visual result to the one i'm looking for, can be seen at:
http://www.badhusid.is/stundatafla.lasso

but here's the situation:
i have a db table with about 100-150 records and i need to create a query
and write out the query result - and html - while trying to go easy on the
resources.

for the sake of this example the table has three columns (in addition to
the id column)

NAME
WEEKDAY
TIME

and i need the data displayed in one html table where the columns are the
weekdays and the records are ordered by time, displaying time and name in
each <td>.

here is the problematic criteria:
- i need all the records from the db table
- i don't know how many records there are on each weekday.
- there is no guarantee for equal amount of records on each weekday
- the time slot is not the same all through each row. (not all days have
name at 08.00)

So I query the database:
SELECT * from table ORDER BY ??
- how should i let SQL order it?
    - by day and then time, or
    - by time and then day

and then i have to build the html table. there are seven columns, but how
many rows? and how do i go about displaying the data.

Here's what i'm thinking, i would appreciate hearing your opinion as well.

I have the possibility to create the html table with one row and seven
columns - thus using nested tables ... i'd rather not, cause i just don't
like nested tables.
pros: i call the db for one day at a time, finish printing that and move on
to next day.
cons: i call the db 7 times

if i'm going to avoid nested tables html's structure tells me i have to get
one item from each day at a time, looping through day1item1, day2item1,
day3item1 before going to day1item2
but i can't really do this without calling the db several times
pros: one html table,
cons: i don't see the solution work.

so any suggestions, guides or other things you'd like to advise me ...?

thanks
elfur







More information about the thelist mailing list