paging problem

Reply

Join Date: Aug 2006
Posts: 24
Reputation: yenyen is an unknown quantity at this point 
Solved Threads: 0
yenyen yenyen is offline Offline
Newbie Poster

paging problem

 
0
  #1
May 16th, 2007
hi,
i have a search form that provide three field for the user to search by firstname, lastname and department(drop down)
then i assign a value for each request.form("")..after tat, whn i do a paging, it jz can display the first page of the record, when i click on the 2nd page and so on or previous..the record no display. the url on the broswer
view_empprofile.asp?page=3&dept=4 can pass the variable but why cant display the record.
do anyone have this experience before? plz guide.
thank you.
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 24
Reputation: yenyen is an unknown quantity at this point 
Solved Threads: 0
yenyen yenyen is offline Offline
Newbie Poster

Re: paging problem

 
0
  #2
May 16th, 2007
  1. <form name="view" method="post" action="<%request.servervariables("script_name")%>">
  2. <table border="1" class="table1" width="100%" cellspacing="0"cellpadding="0" >
  3. <tr>
  4. <th colspan="4" class="TH_COLOR" valign="top">Search Employee Profile</th></tr>
  5. <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>
  6. <tr><td class="tiptext" width="5%"> First Name :</td>
  7. <td width="10%"><input type="text" name="firstname" class="INPUT" size="20" value="<%=firstname%>"></td></tr>
  8. <tr><td class="tiptext" width="5%"> Last Name :</td>
  9. <td width="10%"><input type="text" name="lastname" class="INPUT" size="20" value="<%=lastname%>"></td>
  10. </tr>
  11. <tr><td class="tiptext" width="5%">Department :</td>
  12. <td width="10%">
  13. <select name="department" value="<%=department%>">
  14. <option value="ALL">All Department</option>
  15. <%
  16. SQLTitle = "select * from tbldepartment order by deptid"
  17. Set Rs = server.CreateObject("ADODB.Recordset")
  18. 'Rs.CursorLocation=adUseClient
  19. Rs.Open SQLTitle,Conn,3,2,1
  20. %>
  21. <%If Rs.RecordCount > 0 Then%>
  22. <%Do While Not Rs.Eof%>
  23. <option value='<%=Rs.Fields("deptid")%>'><%=Rs.Fields("deptname")%></option>
  24. <%Rs.MoveNext%>
  25. <%Loop%>
  26. <%End If%>
  27. <%set rs=nothing%>
  28. </select>
  29. </td>
  30. </tr>
  31. <td colspan="2" align="right">
  32. <input type="submit" name="btnsearch" value="Search" class="button_in">
  33. <input type="reset" name="btnreset" value="Reset" class="button_in"></td>
  34. </tr>
  35. <tr><td colspan="4">&nbsp;</td></tr>
  36. </table>
  37. </form>
  38. <%
  39. If request.form("btnSearch") <> ""then
  40. if request.form("firstname")<>"" then
  41. fname=request.form("firstname")
  42. else
  43. fname=request.QueryString("first")
  44. end if
  45. if request.form("lastname")<>"" then
  46. lname=request.form("lastname")
  47. else
  48. lname=request.queryString("last")
  49. end if
  50. if request.form("department")<>"" then
  51. dept=request.form("department")
  52. else
  53. dept=request.queryString("Dep")
  54. end if
  55. iPagesize=1
  56. If Request.QueryString("page") = "" Then
  57. iPageCurrent = 1
  58. Else
  59. iPageCurrent = ConvertDbl(Request.QueryString("page"))
  60. End If
  61. set rs1=server.createobject("ADODB.RECORDSET")
  62.  
  63. if dept="ALL" then
  64. 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&"%')"
  65. else
  66. 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&"')"
  67. end if
  68. rs1.PageSize = iPageSize
  69. rs1.CacheSize = iPageSize
  70. rs1.open sql,conn,3,2,1
  71. iPageCount = rs1.PageCount
  72. If iPageCurrent > iPageCount Then
  73. iPageCurrent = iPageCount
  74. End If
  75.  
  76. If iPageCurrent < 1 Then
  77. iPageCurrent = 1
  78. End If
  79. %>
  80. <%
  81. if rs1.RecordCount>0 then
  82. i=1
  83. rs1.AbsolutePage=iPageCurrent
  84. iRecordsShown = 0
  85. %>
  86. <table cellspacing="0" cellpadding="0" width="100%" align="center" border="1" class="table">
  87. <tr class="TH_COLOR">
  88. <td width="25%" nowrap>Full Name</td>
  89. <td width="25%" nowrap>Position</td>
  90. <td width="25%" nowrap>Department</td>
  91. <td width="8%">View </td>
  92. <td width="8%">Edit</td>
  93. <td width="8%" nowrap>Delete</td>
  94. </tr>
  95. <%do while not rs1.eof and iRecordsShown<iPageSize
  96. fullname=rs1("firstname") & " " & rs1("lastname")
  97. %>
  98. <tr>
  99. <td class="text"><%=fullname%></td>
  100. <td class="text"><%=rs1("postname")%>&nbsp;</td>
  101. <td class="text"><%=rs1("deptname")%>
  102. </td>
  103. <td class="text"><input type="image" src="../image/searching.gif" value="Submit" alt="View" width="25px" height="25px"onClick="javascript:popUpDetail('empdetail.asp?empid=<%=Rs1("empid")%>&memView=true',500,600)">
  104. </td>
  105. <td class="text"><input type="image" src="../image/edit.gif" value="Submit" alt="Edit" width="25px" height="25px"onClick="javascript:popUpDetail('empdetailedit.asp?empid=<%=Rs1("empid")%>&memView=true',500,600)">
  106. </td>
  107. <form method="post" action="deleteemp.asp?ID=<%=rs1("empid")%>" id="submitform" name="submitform">
  108. <td class="text"><input type="image" src="../image/delete.gif" value="Submit" alt="Delete" width="25px" height="25px"onClick="return confirmdelete()">
  109. </td>
  110. </form>
  111. </tr>
  112. <%
  113. iRecordsShown=iRecordsShown+1
  114. rs1.movenext
  115. i=i+1
  116. loop
  117. %>
  118. <tr>
  119. <td>Halaman: [ <%=iPageCurrent%>/<%=iPageCount%> ]</td>
  120.  
  121. <%If iPageCurrent > 1 Then%>
  122. <td> <a href="<%=Request.Servervariables("script_name")%>?page=<%=Server.URLEncode(iPageCurrent-1)%>&Dep=<%=dept%>&first=<%=fname%>&last=<%=lname%>"><<</a></td>
  123. <%End If%>
  124.  
  125. <td>
  126. <%For i = 1 To iPageCount%>
  127. <%If i = iPageCurrent Then%>
  128. <b>[<%=i%>]</b>
  129. <%Else%>
  130.  
  131. <a href="<%=Request.Servervariables("Script_Name")%>?page=<%=Server.URLEncode(i)%>&Dep=<%=dept%>&first=<%=fname%>&last=<%=lname%>"><b><%=i%></b></a> <%End If%>
  132. <%Next%>
  133. </td>
  134. <%If iPageCurrent < iPageCount Then%>
  135. <td><a href="<%=Request.Servervariables("Script_Name")%>?page=<%=Server.URLEncode(iPageCurrent+1)%>&Dep=<%=dept%>&first=<%=fname%>&last=<%=lname%>">>></a> </td>
  136. <%End If%>
  137. <%Set rs = Nothing%>
  138.  
  139. </tr>
  140. <%
  141. end if
  142. end if%>
  143. </table>


this is the code that i write. i hope can hear from you all soon. thanx
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the ASP Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC