Wrox Programmer Forums
| 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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
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

hello
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

etc....

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

Books
Communications
Computers & Internet
Electronics
e-Fax
GSM
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

1newday


 
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
Default

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:

Code:
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:

Code:
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>"
Wend

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





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





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.