CodeCharge Studio
search Register Login  

Web Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge -> General/Other

 Counting Records Question

Print topic Send  topic

Author Message
brandx


Posts: 29
Posted: 04/05/2004, 4:09 PM

Hi all

Codecharge 2.0.7
ASP/Access

I'm able to count the total records in my database no problem using;

'-------------------------------
' Build base SQL statement
'-------------------------------
sSQL = "select [l].[ID] as l_ID " & _
" from [listings] l "
'-------------------------------

'-------------------------------
' RecCount Open Event start
sSQL="select count(ID) as l_ID from listings as l"
' RecCount Open Event end
'-------------------------------

But i'm having trouble figuring out how to count the records that are in a particular directory in my database... I want it to tell me the total records based on the category they are in.

I've tried appending "where LCategory=LCategory"... that don't work..

I've tried appending "where LCategory=1" (the id of the category) that works... but i don't want the category id static like that.... I want it take the category value based on the category search they just performed....

Hope that makes sense..... :*)


TIA,
Geary
View profile  Send private message
Marcus


Posts: 49
Posted: 04/07/2004, 8:26 AM

What do you mean by "particular directory in my database..."

This is what I do for counting records:


CC does this for you:
' Initialize page counter and records per page
'-------------------------------
iRecordsPerPage = 10
iCounter = 0
'-------------------------------

'-------------------------------
' Process page scroller
'-------------------------------
iPage = GetParam("FormBugs_Page")
if IsEmpty(iPage) then iPage = 1 else iPage = CLng(iPage)
openrs rsCount, sCountSQL
dResult = CLng(rsCount.fields(0).value) / iRecordsPerPage
iPageCount = int(dResult)
if iPageCount < dResult then iPageCount = iPageCount + 1
SetVar "BugsPageCount", iPageCount
set rsCount = nothing
while not rs.eof and iCounter < (iPage-1)*iRecordsPerPage
rs.movenext
iCounter = iCounter + 1
wend
iCounter = 0
'-------------------------------





Do when you first display a table upon entering your application:
'-------------------------------
' Open Event begin
'==================================
' Count of found records
'----------------------------------
fResult = dResult * iRecordsPerPage
SetVar "RecsFound", fResult


Do this for all sub-sequent grid displays:
'-------------------------------
' Show Event begin
'==================================
' Count of items in a page
'----------------------------------
Counter1=iCounter+1
SetVar "ItemsOnPage", Counter1
'
'==================================
' Current page number
'----------------------------------
Counter2=iPage
SetVar "pages", iPage
'
'==================================
' Count of found records
'----------------------------------
fResult = dResult * iRecordsPerPage
SetVar "RecsFound", fResult
' Bugs Show Event end
View profile  Send private message
brandx


Posts: 29
Posted: 04/07/2004, 8:37 AM

Sorry.. i didn't mean "directory" .. i meant "category"... I want the total records based on the category that the user is viewing.....

Here's my site... as you'll see.. i have the total records in the database... once you select a category, a subset of the records are visible. I would like the number of records that are in a category. Even better still.... it would be nicer if the number of records show where the number of records returned in the search.. so if i went to a category it would show the number of records in it... but if i also filter the records say by..... category, State, Country it would give me a count on the total number of records returned

http://www.wildlifeinthecity.com/directory/MainPage.asp


TIA,
Geary
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Web Database

Join thousands of Web developers who build Web applications with minimal coding.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.