SunQuest
 
           Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsOtherProgramming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
You eat, breathe and sleep innovation. Build your mobile intelligence with BlackBerry® experts this July. Register Today!
  #1  
Old December 17th, 2003, 03:21 AM
MyFirstASP MyFirstASP is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 4 MyFirstASP User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Unhappy count number of search results

Hi all,

I'm a newbie in ASP here and I need some help from those experts out there

I'm trying to display the total number of records for every different items from a search result. Say that in my access DB there is a field called Products. In it is stored 4 different kinds of products (Prod A, Prod B, Prod C and Prod D). Lets say the total number of records in the DB for each products are:

Products----Total
Prod A--------3
Prod B--------6
Prod C-------32
Prod D-------1

Say I typed in some name that starts with 'M' in the search field. The search results will be:

Name------------Products
Mr. W--------------Prod A
Ms. X-------------Prod A
Mrs. Y--------------ProdC
Ms. Z------------Prod B

Now I have to create a table in my ASP page where it displays something like below:

Products------Totals_From_Search_Results
Prod A---------2
Prod B--------1
Prod C--------1
Prod D--------0

Do you think this is possible? I'm using Access/ASP and am totally stumped. Hope to hear from u guys soon~

Reply With Quote
  #2  
Old January 1st, 2004, 01:41 PM
Skip's Avatar
Skip Skip is offline
Contributing User
ASP Free Novice (500 - 999 posts)
 
Join Date: Nov 2003
Location: UK
Posts: 816 Skip User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 21 m 47 sec
Reputation Power: 5
Well ermm Im not sure what it is you want to achive and you have some issuses with your Db design Name is a reserved word so you should change this to something like Seller_Name

*Arghhg

Brains gone :¬|

Ill think of somthing and repost in a sec

Last edited by Skip : January 1st, 2004 at 01:50 PM.

Reply With Quote
  #3  
Old January 1st, 2004, 02:44 PM
Memnoch's Avatar
Memnoch Memnoch is offline
Unholy Moderator
ASP Free God 14th Plane (11500 - 11999 posts)
 
Join Date: Oct 2003
Location: In hell, where did you think?
Posts: 11,738 Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 3 Weeks 5 Days 1 h 34 m 28 sec
Reputation Power: 443
post what your database structure looks like.
Tables, fieldNames, etc...

Reply With Quote
  #4  
Old January 4th, 2004, 06:59 PM
MyFirstASP MyFirstASP is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 4 MyFirstASP User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hi guys,

Forgot to say I've found the solution a couple of days ago. Sorry for taking your time. Anyone interested can take a look at the codes I used below. Found it in some website. Cheerio!


<%
call query2table("SELECT Field1, COUNT(Field1) AS Search FROM MyTableName WHERE " & u_where &" LIKE '%%"& u_search & "%%' GROUP BY Field1")
%>

<%
sub query2table(inputquery)
DIM conntemp,myPath
SET conntemp = Server.CreateObject("ADODB.Connection")
myPath = Server.MapPath("database.mdb")
conntemp.Open "Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & myPath & ";"

SET rstemp=conntemp.execute(inputquery)
howmanyfields=rstemp.fields.count -1%>

<table width="36%" border="0" cellspacing="1" cellpadding="2" height="161">
<tr>
<td height="98">
<table border=1 bordercolor="#000066" bgcolor="#0066CC" align="center">
<tr>
<% 'Put Headings On The Table of Field Names
for i=0 to howmanyfields %>
<td><b><font color="yellow"><%=rstemp(i).name%></font></b></td>
<% next %>
</tr>
<% ' Now lets grab all the records
do while not rstemp.eof %>
<tr>
<% for i = 0 to howmanyfields
thisvalue=rstemp(i)
If isnull(thisvalue) then
thisvalue="&nbsp;"

end if%>
<td valign=top><%=thisvalue%></td>
<% next %>
</tr>
<%rstemp.movenext
loop%>
</table>
<%
rstemp.close
set rstemp=nothing
conntemp.close
set conntemp=nothing
end sub%>
<div align="center"><b></b></div>
<div align="center"></div>
</td>
</tr>
</table>

Reply With Quote
Reply

Viewing: ASP Free ForumsOtherProgramming Help > count number of search results


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway