Formatting dynamic tables

Discussion in 'ASP General' started by Debbie Davis, Jan 11, 2004.

  1. Debbie Davis

    Debbie Davis Guest

    Greetings,

    I have a table called locations which holds 9 store locations. I am at
    my wit's end trying to format these like this:

    centered

    City Name(named once)
    store store store store

    next, etc.

    Here's my dilemna: Some cities only have 1 location, some have 4, some
    have 3. I don't know how to dynamically get them all centered under the
    city names (which I only need listed once) because of the different
    number of stores for each city. Thanks in advance.

    dd


    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    Debbie Davis, Jan 11, 2004
    #1
    1. Advertising

  2. Debbie Davis

    Tom B Guest

    Dim sSQL
    sSQL="SELECT CityName, StoreName from Locations ORDER BY CityName"
    Set RS=CN.Execute(sSQL)
    Dim sCurrentCity
    if not RS.EOF Then
    Do While not RS.EOF
    if sCurrentCity<>RS.Fields("CityName") then
    'it's the next city.
    sCurrentCity=RS.Fields("CityName")
    Response.Write "<br>" & sCurrentCity & "<br>"
    end if
    'Display the store name (and other information)
    Response.Write RS.Fields("StoreName") & " "

    RS.MoveNext
    Loop
    end if
    Set RS=nothing
    CN.Close
    Set CN=nothing

    The Recordset returned will look like this.......
    Las Vegas Store1
    Las Vegas Store 2
    Paris Store3
    Paris Store4
    Paris Store5

    All you have to do is loop through the recordset, each time you get a new
    city name, then write it out.

    All leave the formatting up to you.


    "Debbie Davis" <> wrote in message
    news:...
    >
    > Greetings,
    >
    > I have a table called locations which holds 9 store locations. I am at
    > my wit's end trying to format these like this:
    >
    > centered
    >
    > City Name(named once)
    > store store store store
    >
    > next, etc.
    >
    > Here's my dilemna: Some cities only have 1 location, some have 4, some
    > have 3. I don't know how to dynamically get them all centered under the
    > city names (which I only need listed once) because of the different
    > number of stores for each city. Thanks in advance.
    >
    > dd
    >
    >
    > *** Sent via Developersdex http://www.developersdex.com ***
    > Don't just participate in USENET...get rewarded for it!
     
    Tom B, Jan 12, 2004
    #2
    1. Advertising

  3. Debbie Davis

    Debbie Davis Guest

    Thanks Tom. It's the formatting I'm having the problem with. I only
    need the city name once then the stores listed across under the city
    name, centered.


    San Antonio
    Store 1 Store 2 Store 3 Store 4

    Austin
    Store 1 Store 2 Store 3

    Etc.

    Where I'm having the problem is centering each row when some cities have
    4 stores, some have 2 some have 1, etc.

    Thanks anyway for your help!!


    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    Debbie Davis, Jan 12, 2004
    #3
  4. Debbie Davis

    Tom B Guest

    What HAVE you got?
    The easiest is to just use....

    <center>San Antonio</center>
    <br>
    <center>Store 1 Store 2 Store 3 Store 4</center>



    "Debbie Davis" <> wrote in message
    news:...
    >
    > Thanks Tom. It's the formatting I'm having the problem with. I only
    > need the city name once then the stores listed across under the city
    > name, centered.
    >
    >
    > San Antonio
    > Store 1 Store 2 Store 3 Store 4
    >
    > Austin
    > Store 1 Store 2 Store 3
    >
    > Etc.
    >
    > Where I'm having the problem is centering each row when some cities have
    > 4 stores, some have 2 some have 1, etc.
    >
    > Thanks anyway for your help!!
    >
    >
    > *** Sent via Developersdex http://www.developersdex.com ***
    > Don't just participate in USENET...get rewarded for it!
     
    Tom B, Jan 12, 2004
    #4
  5. Debbie Davis

    Debbie Davis Guest

    Thanks again, Tom. I really didn't want to post all of this but here
    goes.

    set loc=objConn.execute("select * from locations")
    Response.Write "<table align=center width='100%'>"
    While NOT loc.EOF
    strCity = loc("city")
    If strCity <> strOldCity Then
    Response.Write "<tr><td valign=top colspan=4 align=center><font
    size=4><strong>" & strCity & "</strong></font><tr>"
    End If
    Response.write "<td align=center><strong>" & loc("geographic") &
    "</strong>"
    Response.write "<br><strong>" & loc("telephone") & "</strong>"
    Response.Write "<br>" & loc("address") & "<br>" & loc("city") & ", " &
    loc("state") & " " & loc("zip")
    strOldCity = strCity
    loc.MoveNext
    Wend
    Response.Write "</table>"

    This works except for the formatting problem. 4 is the highest number
    of stores per city, and of course that centers properly, but the next
    city has 1, the next has 3 and they are aligned to the left. It's no
    big deal. I'll just align everything left, but it would look better
    centered.

    Many thanks again, though for all of your help. Your method works
    great, also.


    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    Debbie Davis, Jan 12, 2004
    #5
  6. Debbie Davis

    Alex G Guest

    This is because the rows with just 1 location aren't column spanning
    across the 4 cells, try putting each city in it's own table, try this

    set loc=objConn.execute("select * from locations")
    bolFirstCity = 1
    While NOT loc.EOF
    strCity = loc("city")
    If strCity <> strOldCity Then
    If not bolFirstCity = 1 then
    Response.Write "</table><br>"
    Else
    bolFirstCity = 0
    End If
    Response.Write "<table align=center width='100%'>"
    Response.Write "<tr><td valign=top colspan=4 align=center><font
    size=4><strong>" & strCity & "</strong></font></td></tr><tr>"
    End If
    Response.write "<td align=center><strong>" & loc("geographic") &
    "</strong>"
    Response.write "<br><strong>" & loc("telephone") & "</strong>"
    Response.Write "<br>" & loc("address") & "<br>" & loc("city") & ", " &
    loc("state") & " " & loc("zip")
    strOldCity = strCity
    loc.MoveNext
    Wend
    Response.Write "</table>"

    Debbie Davis <> wrote in message news:<OlM#>...
    > Thanks again, Tom. I really didn't want to post all of this but here
    > goes.
    >
    > set loc=objConn.execute("select * from locations")
    > Response.Write "<table align=center width='100%'>"
    > While NOT loc.EOF
    > strCity = loc("city")
    > If strCity <> strOldCity Then
    > Response.Write "<tr><td valign=top colspan=4 align=center><font
    > size=4><strong>" & strCity & "</strong></font><tr>"
    > End If
    > Response.write "<td align=center><strong>" & loc("geographic") &
    > "</strong>"
    > Response.write "<br><strong>" & loc("telephone") & "</strong>"
    > Response.Write "<br>" & loc("address") & "<br>" & loc("city") & ", " &
    > loc("state") & " " & loc("zip")
    > strOldCity = strCity
    > loc.MoveNext
    > Wend
    > Response.Write "</table>"
    >
    > This works except for the formatting problem. 4 is the highest number
    > of stores per city, and of course that centers properly, but the next
    > city has 1, the next has 3 and they are aligned to the left. It's no
    > big deal. I'll just align everything left, but it would look better
    > centered.
    >
    > Many thanks again, though for all of your help. Your method works
    > great, also.
    >
    >
    > *** Sent via Developersdex http://www.developersdex.com ***
    > Don't just participate in USENET...get rewarded for it!
     
    Alex G, Jan 12, 2004
    #6
  7. Debbie Davis

    Roland Hall Guest

    Hi Debbie...

    Something similar to this?
    http://kiddanger.com/lab/storesandcities.asp

    --
    Roland

    This information is distributed in the hope that it will be useful, but
    without any warranty; without even the implied warranty of merchantability
    or fitness for a particular purpose.
    -Technet Knowledge Base-
    http://support.microsoft.com/default.aspx?scid=fh;EN-US;kbhowto&sd=TECH&ln=EN-US&FR=0
    -Technet Script Center-
    http://www.microsoft.com/technet/treeview/default.asp?url=/technet/scriptcenter/default.asp
    -MSDN Library-
    http://msdn.microsoft.com/library/default.asp
     
    Roland Hall, Jan 12, 2004
    #7
  8. Debbie Davis

    Debbie Davis Guest

    WOW, thanks Alex. That makes perfect and also worked perfectly. Many
    thanks again!!



    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    Debbie Davis, Jan 12, 2004
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. mark
    Replies:
    2
    Views:
    456
  2. Peter Bassett
    Replies:
    3
    Views:
    930
    Augustus
    Aug 15, 2003
  3. Otuatail

    Tables within tables

    Otuatail, Jul 31, 2004, in forum: HTML
    Replies:
    7
    Views:
    498
  4. Replies:
    1
    Views:
    353
    Travis Newbury
    Jun 4, 2005
  5. Chris Brat
    Replies:
    5
    Views:
    697
    =?iso-8859-1?q?Luis_M._Gonz=E1lez?=
    Aug 22, 2006
Loading...

Share This Page