Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Formatting dynamic tables

Reply
Thread Tools

Formatting dynamic tables

 
 
Debbie Davis
Guest
Posts: n/a
 
      01-11-2004

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!
 
Reply With Quote
 
 
 
 
Tom B
Guest
Posts: n/a
 
      01-12-2004
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>
> 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!



 
Reply With Quote
 
 
 
 
Debbie Davis
Guest
Posts: n/a
 
      01-12-2004

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!
 
Reply With Quote
 
Tom B
Guest
Posts: n/a
 
      01-12-2004
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>
> 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!



 
Reply With Quote
 
Debbie Davis
Guest
Posts: n/a
 
      01-12-2004


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!
 
Reply With Quote
 
Alex G
Guest
Posts: n/a
 
      01-12-2004
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 <(E-Mail Removed)> wrote in message news:<OlM#(E-Mail Removed)>...
> 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!

 
Reply With Quote
 
Roland Hall
Guest
Posts: n/a
 
      01-12-2004
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...&ln=EN-US&FR=0
-Technet Script Center-
http://www.microsoft.com/technet/tre...er/default.asp
-MSDN Library-
http://msdn.microsoft.com/library/default.asp


 
Reply With Quote
 
Debbie Davis
Guest
Posts: n/a
 
      01-12-2004
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!
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to get database metadata information (i.e. existing tables and columns in tables) Chris Brat Python 5 08-22-2006 05:25 PM
Not using tables for complex formatting markalroberts@gmail.com HTML 1 06-04-2005 02:23 PM
Tables within tables Otuatail HTML 7 08-02-2004 04:42 AM
page formatting problem with tables and datagrids - especially printing mark ASP .Net 2 06-09-2004 08:32 AM
Text after 2 tables actually appears between 2 tables ! Peter Bassett HTML 3 08-15-2003 06:46 PM



Advertisments