%@ CodePage=65001 %>
<% call connect() %>
<%
search=Trim(request.Querystring("txtsearch"))
if search <>"" then
Categoryname="Search Results"
else
'strauth=trim(request.QueryString("auth"))
'id = request_equerystring(decrypt(strauth),"id")
id=Replace(Trim(Request.QueryString("id")),"'","''")
if not isnumeric(id) then
response.Redirect("index.asp")
end if
'CategoryId=cint(id)'
Session("CategoryId")=cint(id)
'********************************************
'FOR CATEGORY TITLE
'********************************************
sql = "SELECT * FROM product_category where id=" & id
set rs_category=cnn.execute(sql)
if not rs_category.eof then
categoryname=StrReplace(rs_category("categoryname"))
end if
set rs_category=nothing
'********************************************
'FOR FEATURED PRODUCT AT TOP
'********************************************
if id<>4 then
sql = "SELECT top 1 * FROM products where categoryid="& id &" and isFeaturedPRoduct='Y' order by SortOrder desc"
else
sql = "SELECT top 4 * FROM products where categoryid="& id &" and isFeaturedPRoduct='Y' order by SortOrder desc"
end if
set rs_featuredproduct=cnn.execute(sql)
end if
'********************************************
'FOR PRODUCT LISTING
'********************************************
set rs_product=Server.CreateObject("ADODB.Recordset")
if search="" then
sql = "SELECT * FROM products where categoryid="& id &" and categoryid<>4 order by SortOrder desc"
else
sql = "SELECT P.* FROM products P,product_category C where P.categoryid=C.id and P.categoryid<>4 and (C.categoryname like '%" & search &"%' OR P.title like '%" & search &"%' OR short_description like '%" & search &"%' OR description like '%" & search &"%' ) order by SortOrder desc"
end if
rs_product.open sql,cnn,1,3
product_cnt=rs_product.recordcount
'FOR PAGINATION
dim rs1, sql1
set rs1 = server.createobject("ADODB.recordset")
sql1 = sql
rs1.open sql1, cnn
pageNumber=Trim(Request.QueryString("page"))
if pageNumber = "" then
pageNumber=1
end if
'BOOKS (ID-1) , MUSIC (ID-3) , DIGITAL DOWNLOAD (ID-4) RECORDS PER PAGE IS 4
'SERMONS (ID-2) RECORDS PER PAGE IS 6
dim perPage, perBook
if cint(id)=2 then
perPage = 6
else
perPage = 6
end if
perBook = 10 'NO.OF PAGES PER BOOK
dim startRecord, endRecord, startBook, endBook
validDisplay = 0
lastNext = false
firstPrevious = false
if pageNumber = 1 then
pageNumber = 1
startRecord = 1
endRecord = perPage
else
getStartEndRecord(pageNumber)
end if
i=1
j = 0
While Not rs1.EOF
j = j + 1
if j >= startRecord then
if j <= endRecord then
validDisplay = validDisplay + 1
end if
end if
rs1.movenext
i=i+1
wend
rs1.close
set rs1= nothing
totalPage = calcNumberOfPage(j)
totalBook = calcNumberOfBook(totalPage)
getStartEndBook(pageNumber)
displayPage = ""
for r = CInt(startBook) to CInt(endBook)
if CStr(pageNumber) = CStr(r) then
'if r = totalPage then
' display = "["&CStr((r*perPage)-(perPage-1))&"-"&CStr(r*perPage)&"]"
'else
' display = "["&CStr((r*perPage)-(perPage-1))&"-"&CStr(r*perPage)&"]"
'end if
if r = totalPage then
display = ""&CStr(r)&""
else
display = ""&CStr(r)&""
end if
else
if r = totalPage then
display = ""&CStr(r)&""
else
display = ""&CStr(r)&""
end if
end if
displayPage = displayPage + display
if r<>endbook then
displayPage = displayPage + " | "
end if
next
%>
Lighthouse Online
<%= categoryname %>
<%
''FREATURED PRODUCT IS TO DISPLAY ONLY IN FIRST PAGE
If pageNumber =1 and search="" Then
%>
<%
function calcNumberOfPage(iteration)
tempPages = 0
tempPages = CInt(iteration/perPage)
if ( (tempPages*perPage) < (iteration) ) then
tempPages = tempPages + 1
end if
calcNumberOfPage = tempPages
end function
function calcNumberOfBook(calcPages)
tempBooks = 0
tempBooks = CInt(calcPages/perBook)
if ( (tempBooks*perBook) < (calcPages) ) then
tempBooks = tempBooks + 1
end if
calcNumberOfBook = tempBooks
end function
sub getStartEndRecord(pageNumber)
startRecord = ((pageNumber - 1) * perPage) + 1
endRecord = pageNumber * perPage
'response.write(" startRecord:"&startRecord)
'response.write(" endRecord:"&endRecord)
end sub
sub getStartEndBook(pageNumber)
for m = 1 to totalBook
startBook = ((m - 1) * perBook) + 1
endBook = m * perBook
if (CInt(pageNumber) >= CInt(pageNumber)) and (CInt(pageNumber) <= CInt(endBook)) then
if CInt(endBook) >= totalPage then
endBook = totalPage
lastNext = true
end if
if CInt(startBook) = 1 then
firstPrevious = true
end if
'Response.write(" m:"&m&":page:"&startBook&":to:"&endBook&"")
Exit for
end if
next
end sub
sub getNextStartEndBook(pageNumber)
for m = 1 to totalBook
startBook = ((m - 1) * perBook) + 1
endBook = m * perBook
if (CInt(pageNumber) >= CInt(pageNumber)) and (CInt(pageNumber) <= CInt(endBook)) then
'Response.write(" m:"&m&":page:"&startBook&":to:"&endBook&"")
startBook = (m * perBook) + 1
endBook = (m + 1) * perBook
Exit for
end if
next
end sub
%>