navigation
a webmaster learning community
     Home    Register     Search      Help      Login    
Sponsors

Shopping Cart Software
Ecommerce software integrated into Frontpage, Dreamweaver and Golive templates. No monthly fees and available in ASP and PHP versions.

Website Templates
We also have a wide selection of Dreamweaver, Expression Web and Frontpage templates as well as webmaster tools and CSS layouts.

Frontpage website templates
Creative Website Templates for FrontPage, Dreamweaver, Flash, SwishMax

Search Forums
 

Advanced search
Recent Posts

 Todays Posts
 Most Active posts
 Posts since last visit
 My Recent Posts
 Mark posts read

Microsoft MVP

 

Count Records and Multiple Pages

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
Printable Version 

All Forums >> Web Development >> ASP and Database >> Count Records and Multiple Pages
Page: [1]
 
xterradane

 

Posts: 143
From: Mobile, AL USA
Status: offline

 
Count Records and Multiple Pages - 9/1/2002 11:25:40   
I am to the point where I need to have multiple pages for search results, but I can' t find the previous code which explained how to implement this. Any ideas where I can find the info or how to do it would be appreciated? Everything is hand coded in ASP.

Gail

:)
Spooky

 

Posts: 26599
Joined: 11/11/1998
From: Middle Earth
Status: offline

 
RE: Count Records and Multiple Pages - 9/1/2002 18:46:48   
Heres an example of paging that may be of use?
http://www.learnasp.com/learn/dbtablepaged.asp



_____________________________

If you arent part of the solution, then there is good money to be made prolonging the problem

§þ:)


(in reply to xterradane)
xterradane

 

Posts: 143
From: Mobile, AL USA
Status: offline

 
RE: Count Records and Multiple Pages - 9/6/2002 12:39:26   
Spooky,

I found some other code that seemed a little less complex for me to understand. However, I am having some problems. I can get the results for the first page and the links are fine. I am getting a ADO error and can' t figure out why since it works on the first page. This is the link to the code I followed:

http://aspfree.com/asp/startpage.asp?id=11

This is a link to my page with the results:

http://www.fit-jobs.com/JobSearchResultsPaging.asp?JobType=Any&State=Any&Get+Jobs=Get+Jobs

Here is my code watered down a bit:

<%
	
	Dim iPageSize				' How big our pages are
	Dim strPageCount			' The number of pages we get back
	Dim strPageCurrent		' The page we want to show
	Dim  x						' Standard looping var
	
	iPageSize = 10
	
	If Request(" page" ) = " "  Then
		strPageCurrent = 1
	End If
	
	If Request(" page" ) <> " "  Then
		strPageCurrent = CInt(Request(" page" ))
	End If
		
	Dim strState, strJobType
	strState = Request(" State" )
	strJobType = Request(" JobType" )
	
	Dim rsJob
	Set rsJob = Server.CreateObject(" ADODB.Recordset" )
	rsJob.CursorLocation = adUseClient 	' Set cursor location
	rsJob.PageSize = iPageSize				' Set page size
	
	If strJobType = " Any"  AND strState = " Any"  Then
		strSQL=" SELECT * FROM Job WHERE DateExpires>= Date() ORDER BY DatePosted DESC;" 
	End If 
	
	If Request(" JobType" ) <> " Any"  AND Request(" State" ) = " Any"  Then
		strSQL=" SELECT * FROM Job WHERE DateExpires>= Date() AND JobType=' "  & strJobType & " '  ORDER BY DatePosted DESC;" 
	End If
	
	If Request(" JobType" ) = " Any"  AND Request(" State" ) <> " Any"  Then
		strSQL=" SELECT * FROM Job WHERE DateExpires>= Date() AND State=' "  & strState & " '  ORDER BY DatePosted DESC;" 
	End If
	
	If Request(" JobType" ) <> " Any"  AND Request(" State" ) <> " Any"  Then
		strSQL=" SELECT * FROM Job WHERE DateExpires>= Date() AND JobType=' "  & strJobType & " '  AND State=' "  & strState & " '  ORDER BY DatePosted DESC;" 
	End If
			
	rsJob.Open strSQL, objConn
	strPageCount = rsJob.PageCount				' Get the count of the pages using the given page size
	
	If 1 > strPageCurrent Then strPageCurrent = 1
	If strPageCurrent > strPageCount Then strPageCurrent = strPageCount
	rsJob.AbsolutePage = strPageCurrent		' Move to the selected page
	
	If rsJob.EOF Then
		Response.Write " <DIV ALIGN=" " CENTER" " >Your search returned no records. Please broaden your search. <P>Also note:" &_
			" We have just released this site and are currently marketing it to prospective companies." 		
	End If
	
	If Not rsJob.EOF Then	
		Response.Write " <FONT SIZE=" " 1" "  FACE=" " VERDANA" " >Displaying Page <B>"  & strPageCurrent & " </B>"  &_
			"  of <B>"  & strPageCount & " </B></FONT><BR><BR>"  & vbCrLf	
		Response.Write " <TABLE ALIGN=" " CENTER" "  STYLE=" " BORDER-COLLAPSE: collapse" "  BORDER=" " 1" "  CELLPADDING=" " 4" "  WIDTH=" " 80%" " >" 	&_	
		" <TR><TH WIDTH=" " 40%" "  bgcolor=" " #0099CC" " ><P ALIGN=" " LEFT" " ><FONT COLOR=" " #FFFFFF" "  SIZE=" " 2" "  FACE=" " VERDANA" " >Job Title</FONT></TH>"  &_
		" 		<TH WIDTH=" " 25%" "  bgcolor=" " #0099CC" " ><FONT COLOR=" " #FFFFFF" "  SIZE=" " 2" "  FACE=" " VERDANA" " >Company</FONT></TH>"  &_
		" 		<TH WIDTH=" " 20%" "  bgcolor=" " #0099CC" " ><FONT COLOR=" " #FFFFFF" "  SIZE=" " 2" "  FACE=" " VERDANA" " >Location</FONT></TH>"  &_
		" 		<TH WIDTH=" " 15%" "  bgcolor=" " #0099CC" " ><FONT COLOR=" " #FFFFFF" "  SIZE=" " 2" "  FACE=" " VERDANA" " >Date Posted</FONT></TH>"  &_
		" 	</TR>" 
	End If
	
	Do While rsJob.AbsolutePage = strPageCurrent AND Not rsJob.EOF  
		Response.Write " <TR ALIGN=CENTER>"  &_
		" <TD P ALIGN=" " LEFT" " > " %>

<a href=" JobDetails.asp?ID=<%= rsJob(" ID" )%>"  style=" color: #0099CC" ><%=rsJob(" JobTitle" ) &" </TD>" %></a><% Response.Write " <TD> "  & rsJob(" CompanyName" ) &" </TD>"  &_
		" <TD> "  & rsJob(" State" ) &" </TD>"  &_
		" <TD> "  & rsJob(" DatePosted" ) &" </TD>"  &_
		" </TR>" 
		rsJob.MoveNext
	Loop
	Response.Write " </TABLE>" 
	
	rsJob.Close
	Set rsJob = Nothing
	
	If strPageCurrent <> 1 Then
		Response.Write " <A HREF = " " ./JobSearchResultsPaging.asp?page=" 
		Response.Write strPageCurrent -1
		Response.Write " " " >Previous Page</A>"  & vbCrLf
		Response.Write "   "  & vbCrLf
	End If
	
	If strPageCurrent < strPageCount Then
		Response.Write " <A HREF=" " ./JobSearchResultsPaging.asp?page=" 
		Response.Write strPageCurrent + 1
		Response.Write " " " >Next Page</A>"  & vbCrLf
	End If
%>


Do you have any ideas of how to fix this problem? Also, is this an okay method (" paging" ) or is there a better method I should be using? You are probably going to say the other article you referenced. If so, I will try it with that, but it seemed so complex with the little brain power I have!:)







< Message edited by xterradane -- 9/5/2002 12:40:18 PM >

(in reply to xterradane)
Spooky

 

Posts: 26599
Joined: 11/11/1998
From: Middle Earth
Status: offline

 
RE: Count Records and Multiple Pages - 9/7/2002 17:29:12   
I think your SQL string is null

If you do this :


If strPageCurrent =2 then
Response.write strSQL
response.end
End if

rsJob.Open strSQL, objConn 


Is the SQL string correct on page 2?

_____________________________

If you arent part of the solution, then there is good money to be made prolonging the problem

§þ:)


(in reply to xterradane)
Page:   [1]

All Forums >> Web Development >> ASP and Database >> Count Records and Multiple Pages
Page: [1]
Jump to: 1





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts