This topic is locked

Search results as a percentage?

11/6/2006 5:40:15 AM
ASPRunnerPro General questions
B
Bryan author

Hi there,
Is there anyone out there who could advise on the following?
Let's say I have a db with 100 records in it. One of the fields in the db is called "Status" and 60 of the records have a Status value of "Ongoing" and 40 have "Complete".
What i'd like achieve, is when I use the "Status" field as a basis for searching it forms the basis for a percentage value.
The percentage would be displayed in the footer in the List page.
For example,
If I use Advanced Search to say "Status=Ongoing" and "Value>2000" and it returns 30 records, the footer would say "50% of Ongoing Cases are > 2000" (as number of Ongoing records = 60, results > 2000 = 30, so Percent=50%).
Or
If "Status=Complete" and "Value>10000" returns 10 records, the footer would say "25% of Settled Cases are > 10000" (Number of Complete records=40, results>10000 =10, so percent=25%)
Any clues?
Thanks,

Bryan

Sergey Kornilov admin 11/6/2006

It looks like you need to add a piece of code to include/footer.asp file that will display this info.

if (request("a"))="advsearch" then
set rstmp=Server.CreateObject("ADODB.Recordset")

rstmp.Open "select count(*) from " & strTableName, dbConnection

Response.Write CLng(100*smarty("records_found")/rstmp(0)) & "%"
rstmp.Close : set rstmp=nothing

end if


If you like to add more info to this message take a look at the following variables:
Request("asearchopt_Status") - search option of Status field (Contains, Equals etc)

Request("value_Status") - search value of Status field

B
Bryan author 11/9/2006

Thanks Sergey, but i'm having difficulty getting this to work.
Would it be possible to provide an working example, using the "Current_Status" field in advanced search and the results displayed in the footer of the list page?
Many thanks,

Bryan

Sergey Kornilov admin 11/9/2006

Bryan,
this is a working example. Unfortunately I don't have better one.
What happens when you put this code to footer.asp?

B
Bryan author 11/15/2006

Hi Sergey,
Apologies for the delay in replying.
When I put this code in the footer, nothing is displayed.
I'm confused with your code as it makes no reference to the Current_Status field? How is anything actually calculated?
Many thanks,

Bryan

Sergey Kornilov admin 11/15/2006

Bryan,
make sure you putting header.asp file into include directory and this code is wrapped by <% ... %>.
This code simply calculates total number of records and calculates percentage based on current advanced search criteria. This code only works in version 4.1 after advanced search performed.

B
Bryan author 11/15/2006

Hi Sergey,
Yes have done that (as a footer, not a header) but it doesn't display anything.
If I put:
response.write "Table:" & strTableName

response.write "Connection" & dbConnection
the footer is displayed on every page as follows:
Table:Connection:
Neither have a value.
Thanks,

Bryan

Sergey Kornilov admin 11/15/2006

Bryan,
if you are a registered ASPRunnerPro user you can send your files to support@xlinesoft.com for investigation.