User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP section within the Web Development category of DaniWeb, a massive community of 426,126 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 1,685 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP advertiser: Lunarpages ASP Web Hosting
Views: 1073 | Replies: 1
Reply
Join Date: Aug 2006
Posts: 23
Reputation: yenyen is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
yenyen yenyen is offline Offline
Newbie Poster

paging problem

  #1  
May 15th, 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.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Aug 2006
Posts: 23
Reputation: yenyen is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
yenyen yenyen is offline Offline
Newbie Poster

Re: paging problem

  #2  
May 16th, 2007
 <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
if request.form("firstname")<>"" then
  fname=request.form("firstname") 
else
  fname=request.QueryString("first")
end if
if request.form("lastname")<>"" then
  lname=request.form("lastname") 
else
  lname=request.queryString("last")
end if
if request.form("department")<>"" then
 dept=request.form("department")
else
 dept=request.queryString("Dep")
end if
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&"%')"
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="javascript: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="javascript: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)%>&Dep=<%=dept%>&first=<%=fname%>&last=<%=lname%>"><<</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=<%=dept%>&first=<%=fname%>&last=<%=lname%>"><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=<%=dept%>&first=<%=fname%>&last=<%=lname%>">>></a> </td>
          <%End If%>
          <%Set rs = Nothing%>
   
        </tr>
<% 
 end if
end if%>
</table>
 


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

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb ASP Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the ASP Forum

All times are GMT -4. The time now is 4:29 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC