<% ' pageLen=15 '30 ' ลิสจำนวนคำถาม / หน้า pageNo = request.QueryString("pageNo") ' เลขหน้าที่ต้องการ if pageNo="" then pageNo = 1 ' ถ้าเลขหน้าไม่มีให้ตั้งค่าเป็น 1 category = request.QueryString("category") ' หมวดคำถาม kword=request.QueryString("kword") ' ข้อความที่ต้องการค้นหา %> <%=strTitle%>
<%=strNewquestion%> | <%=strListquestions%> | <%=strHome%> <% if showAdminLink=1 then %>| Admin <% end if %>
Search ค้นหาคำถามที่มีคำว่า (ไม่ใส่จะแสดงทั้งหมด)     

<% if kword <> "" or cint(category) <> 0 then response.write "
แสดงเฉพาะคำถาม" if kword <> "" then response.write("ที่มีคำว่า : " & kword & " ") end if Dim Conn 'Set Conn = Server.CreateObject("ADODB.Connection") 'Conn.Open "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" &_ 'Server.MapPath("/database/QAboard.mdb")&_ '";uid=admin;password=demo" %> <% Set RS =Server.CreateObject("ADODB.Recordset") category =0 if category < 1 then ' ค้นหาข้อความที่ต้องการในทุกหมวด Sql="Select * from question where Qdetail like '%" _ & kword & "%' or topic like '%" & kword & _ "%' order by qNo desc" Else ' ค้นหาข้อความที่ต้องการเฉพาะหมวดที่เลือก Sql="Select * from question where (Qdetail like '%" _ & kword & "%' or topic like '%" & kword &_ "%' ) and category=" & category & _ " order by qNo desc" end if RS.open Sql,Conn,1,3 Nrecord=RS.recordcount 'number of record rs.pageSize = pageLen totalPage = rs.PageCount ' จำนวนหน้าทั้งหมด if not rs.eof then rs.absolutePage = pageNo ' ป้องกัน error ถ้าไม่มี record อยู่เลย %> <% recNo = 1 ' ตัวนับจำนวนเรคอร์ดที่แสดงขณะนี้ Do While Not RS.EOF and recNo <= pageLen 'list question %> <% RS.MoveNext recNo=recNo+1 Loop rs.close conn.close set rs = nothing set conn = nothing %>
<%= "Q" & right("0000" & RS("qNo"),5) %>   " target=_blank> <%=RS("topic")%> - <%=RS("name")%> - <%=day(RS("Date"))%>/<%=month(RS("Date"))%>/<%=right(year(RS("Date")),2)%>    (ดู  <%=RS("Category")%>   ตอบ <%=RS("answer")%>) <%if session("adlevel")=1 then %>  <%=RS("email")%> -     " target=_blank> Edit (แก้ไข) <% end if %>
supported by itpart.com
จำนวน: <%=Nrecord%> คำถาม, ขณะนี้อยู่หน้า <%=pageNo%> ในทั้งหมด <%=totalPage%> หน้า - <% ' ปุ่มคลิก หน้าต่อไป หรือ ย้อนกลับ if cint(pageno) > 1 then %> [หน้าแรก]  [ย้อนกลับ]  <% end if if cint(pageno) < totalPage then %> [หน้าต่อไป]  [หน้าสุดท้าย]  <% end if ' -- link ไปหน้าใดๆได้เลย %>
กระโดดไปหน้า | <% for idx = 1 to totalPage %><%=idx%>  <% next %> |