Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP 3 Classic ASP Active Server Pages 3.0 > ASP Forms
Password Reminder
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP Forms As of Oct 5, 2005, this forum is now locked. Please use "Classic ASP beginner" at http://p2p.wrox.com/forum.asp?FORUM_ID=54 or "Classic ASP Professional" http://p2p.wrox.com/forum.asp?FORUM_ID=56 instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP Forms section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 11th, 2004, 04:58 PM
Registered User
Join Date: Jul 2004
Location: , , .
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default formatting a classifieds section

i have a database table with a foreign key reference from another table. Which is the Markets table.

I now have a products column. As below
      Market Products descriptions
  Electronics sonyJ70 2003 sony mobile phone
  Electronics Binatone 3000 Binatone toaster
 Computers Dell navasion300 Dell desktops


i created a repeated region on my site. So all Markets would be repeated.
e.g you have

Computers & Internet
web2phone SMS

now i want to be able to select the total number of products from the table and have them inserted into the repeated region of the markets area. to have

Books (340)
Communications (44)
Computers & Internet (1923)
Electronics (232)
e-Fax (32)
GSM (23)
web2phone SMS (31)

How do i go about this ? I am made to understand that i use ASP scripts to loop through the query results to format the page as above

Thank you


  #2 (permalink)  
Old August 11th, 2004, 08:16 PM
Authorized User
Join Date: Aug 2004
Location: Chicago, IL, USA.
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts

The the fastest way would be to use a query with the COUNT function to count how many products there are in each market. Example:

SELECT COUNT(market) AS marketCount FROM tableName WHERE market = 'Electronics'
You would have to run the query for each individual market, but if you're looping through the markets already, this shouldn't be too big a of a deal. If you're using a database other then access, you might be able to use the COUNT function in conjunction with the DISTINCT function, which would save you a lot of trouble, so let us know if you're not using access.

A quick (and dirty) example:

Set varRsMarkets = Server.CreateObject("ADODB.Recordset")
Set varRsMCount = Server.CreateObject("ADODB.Recordset")

strSql = "SELECT market FROM marketsTable"
varRsMarket.Open strSql, yourConnection

While NOT varRs.EOF
     strSql = "SELECT COUNT(market) AS marketCount FROM productTable WHERE market = '" & varRs("market") & "'"
     varRsMCount.Open strSql, yourConnection
     response.write varRs("market") & "(" & varRsMCount("marketCount") & ")<br>"

That will list all the markets and the number of products in that market.


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Add a CDATA section; add nodeset to CDATA section kssudhish XSLT 3 January 3rd, 2008 07:13 AM
formatting a classifieds section. Part 2 afrika_people Classic ASP Databases 1 August 13th, 2004 04:40 PM
Section formatting cankalu Crystal Reports 1 May 31st, 2004 07:28 PM
Formatting Report Detail Section rickf Access 3 February 3rd, 2004 07:15 PM

All times are GMT -4. The time now is 09:02 PM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.