3 Replies - 1620 Views - Last Post: 19 May 2007 - 05:09 AM Rate Topic: -----

#1 little sushi  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 15-May 07

paging

Posted 15 May 2007 - 09:53 PM


<form name="view" method="post" action="<%request.servervariables("script_name")%>">
	  <table border="1" class="table1" width="100%" cellspacing="0"cellpadding="0" >
	  <tr>
	  <th colspan="4" class="TH_COLOR" valign="top">Search Employee Profile</th></tr>
	  <tr><td colspan="4"><img src="../image/searching.gif" height="40" width="40"> &nbsp; <font color="red" size="3">*Please key in the employee first name, last name or department.</font></td></tr>
	  <tr><td class="tiptext" width="5%"> First Name :</td>
	  <td width="10%"><input type="text" name="firstname" class="INPUT" size="20" value="<%=firstname%>"></td>
	  </tr>
	  <tr><td class="tiptext" width="5%"> Last Name :</td>
	  <td width="10%"><input type="text" name="lastname" class="INPUT" size="20" value="<%=lastname%>"></td>
	  </tr>
	  
	  <tr><td class="tiptext" width="5%">Department :</td>
	  <td width="10%">
			  <select name="department" value="<%=department%>">
		   <option value="ALL">All Department</option>	
	
		<%											
			SQLTitle = "select * from tbldepartment order by deptid"
			Set Rs = server.CreateObject("ADODB.Recordset")
			'Rs.CursorLocation=adUseClient
			Rs.Open SQLTitle,Conn,3,2,1 
		%>
			<%If Rs.RecordCount > 0 Then%>
			<%Do While Not Rs.Eof%>
			<option value='<%=Rs.Fields("deptid")%>'><%=Rs.Fields("deptname")%></option>
			<%Rs.MoveNext%>
			<%Loop%>
			<%End If%>
			<%set rs=nothing%>
			
			</select>
	  </td>
	  </tr>
	  <td colspan="2" align="right">
	  <input type="submit" name="btnsearch" value="Search" class="button_in">
	  <input type="reset" name="btnreset" value="Reset" class="button_in"></td>
	  </tr>
	  <tr><td colspan="4">&nbsp;</td></tr>
	  </table>
	  </form>
	
<%

'If request.form("btnSearch") <> ""then

fname=request("firstname")
lname=request("lastname")
dept=request("department")

iPagesize=1
If Request.QueryString("page") = "" Then
iPageCurrent = 1
Else
iPageCurrent = ConvertDbl(Request.QueryString("page"))   
End If

set rs1=server.createobject("ADODB.RECORDSET")		
	
if dept="ALL" then
SQL="SELECT  A.empid, A.firstname,A.lastname,B.deptname,C.postname FROM tbl_employee A LEFT OUTER JOIN tbldepartment B ON A.department = B.deptid LEFT OUTER JOIN tbl_position C ON A.position=C.postID WHERE  (A.firstname LIKE '"&fname&"%') AND (A.lastname LIKE '"&lname&"%')"
'response.write sql
'response.end
else
sql="SELECT A.empid, A.firstname,A.lastname,B.deptname,C.postname FROM tbl_employee A INNER JOIN tbldepartment B ON A.Department = B.Deptid  INNER JOIN tbl_position C ON A.position=C.postID WHERE (A.firstname LIKE '"&fname&"%')AND (A.lastname LIKE '"&lname&"%') AND (A.department = '"&dept&"')"
end if

rs1.PageSize = iPageSize
rs1.CacheSize = iPageSize
rs1.open sql,conn,3,2,1	

iPageCount = rs1.PageCount		

	If iPageCurrent > iPageCount Then
	iPageCurrent = iPageCount
	End If
		
	If iPageCurrent < 1 Then
	iPageCurrent = 1
	End If		

%>
<%	 
if rs1.RecordCount>0 then
 		i=1
 		rs1.AbsolutePage=iPageCurrent
		iRecordsShown = 0
%>

<table cellspacing="0" cellpadding="0" width="100%" align="center" border="1" class="table">

<tr class="TH_COLOR">
<td width="25%" nowrap>Full Name</td>
<td width="25%" nowrap>Position</td>
<td width="25%" nowrap>Department</td>
<td width="8%">View </td>
<td width="8%">Edit</td>
<td width="8%" nowrap>Delete</td>

</tr>

<%do while not rs1.eof and iRecordsShown<iPageSize
fullname=rs1("firstname") & " " & rs1("lastname")
%>

<tr>
<td class="text"><%=fullname%></td>
<td class="text"><%=rs1("postname")%>&nbsp;</td>
<td class="text"><%=rs1("deptname")%>
</td>
<td class="text"><input type="image" src="../image/searching.gif" value="Submit" alt="View" width="25px" height="25px"onclick="java script:popUpDetail('empdetail.asp?empid=<%=Rs1("empid")%>&memView=true',500,600)">
</td>
<td class="text"><input type="image" src="../image/edit.gif" value="Submit" alt="Edit" width="25px" height="25px"onclick="java script:popUpDetail('empdetailedit.asp?empid=<%=Rs1("empid")%>&memView=true',500,600)">
</td>
<form method="post" action="deleteemp.asp?ID=<%=rs1("empid")%>" id="submitform" name="submitform">
<td class="text"><input type="image" src="../image/delete.gif" value="Submit" alt="Delete" width="25px" height="25px"onclick="return confirmdelete()">
</td>
</form>
</tr>
<% 
iRecordsShown=iRecordsShown+1
	rs1.movenext
	i=i+1
	loop
%>

 <tr>
  <td>Halaman: [ <%=iPageCurrent%>/<%=iPageCount%> ]</td>
  
  <%If iPageCurrent > 1 Then%>
   <td> <a href="<%=Request.Servervariables("script_name")%>?page=<%=Server.URLEncode(iPageCurrent-1)%>&Dept=<%=request("department")%><% if fname <>"" then%>&first=<%=request("firstname")%><%end if%><% if lname <>"" then%>&last=<%=request("lastname")%><%end if%>"><<</a></td>
   <%End If%>
 
   <td>
			<%For i = 1 To iPageCount%>
			<%If i = iPageCurrent Then%>
			<b>[<%=i%>]</b>
			<%Else%>
			
   <a href="<%=Request.Servervariables("Script_Name")%>?page=<%=Server.URLEncode(i)%>&Dep=<%=request("department")%><% if fname <>"" then%>&first=<%=request("firstname")%><% end if%><% if lname <>"" then%>&last=<%=request("lastname")%><% end if%>"><b><%=i%></b></a>   
   
   <%End If%>
			<%Next%>
		  </td>
		  <%If iPageCurrent < iPageCount Then%>
		  <td><a href="<%=Request.Servervariables("Script_Name")%>?page=<%=Server.URLEncode(iPageCurrent+1)%>&Dep=<%=request("department")%><% if fname <>"" then%>&first=<%=request("firstname")%><% end if%><% if lname <>"" then%>&last=<%=request("lastname")%><% end if%>">>></a> </td>
		  <%End If%>
		 
		</tr>

<%	
	end if
'end if%>
</table>




i wan to do a paging after the user search the reford. but when i wan to click to the secodn page, it cant dispaly any record for me. can help me to check my code? thanx

Is This A Good Question/Topic? 0
  • +

Replies To: paging

#2 JellyBean  Icon User is offline

  • D.I.C Head

Reputation: 6
  • View blog
  • Posts: 60
  • Joined: 25-April 07

Re: paging

Posted 16 May 2007 - 01:05 PM

This is gonna be a difficult one to help you with because we don't have access to the same database as you....

This tutorial might help you. If you need some slightly more advanced techniques, here is another tutorial that will point the way.
Was This Post Helpful? 0
  • +
  • -

#3 little sushi  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 15-May 07

Re: paging

Posted 16 May 2007 - 06:06 PM

Attached ImageAttached Image

View PostJellyBean, on 16 May, 2007 - 01:05 PM, said:

This is gonna be a difficult one to help you with because we don't have access to the same database as you....

This tutorial might help you. If you need some slightly more advanced techniques, here is another tutorial that will point the way.


the table name : tbl_employee
---------------------empid, firstname, lastname, icnum, department, position


tbldepartment
deptid
deptname

this is the two table involve. plz...help......i really dont know how to debug on it. :crazy: plzzzz.

i have attached two screenshot of the problem. when i submit the search form, with the name keyword is "ch" and department is IT..then the search result will display as image 1.gif..(there is 2 records was found) but when i click on the paging 2nd page, it dispaly all the records in the tables(go to the select * sql without where clause) same as 2.jpg.

i hope can hear from you all soon...

thanx..

This post has been edited by little sushi: 16 May 2007 - 06:11 PM

Was This Post Helpful? 0
  • +
  • -

#4 JellyBean  Icon User is offline

  • D.I.C Head

Reputation: 6
  • View blog
  • Posts: 60
  • Joined: 25-April 07

Re: paging

Posted 19 May 2007 - 05:09 AM

Sorry, I just realised that you are using original ASP.... Unfortunately I only know ASP.NET.

I did find an article on ADO Recordset Paging in ASP. Maybe someone else can help with ASP?

Best of luck to you.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1