Hi, guys. How are you?
Please help me.
I have a serious problem.
I made shopping catalogue. It shows each product according to menu.
Menu has Pendants, Bangles, Collors and so on.
When user go to each items, I didn't want to show all the item on the same page.
I tried to show 7 each pages. And made page index at the bottom of the page.
It looked every fine. I am quite pleased until I clicked page 2.
Some reason, when I click page inex number whatever, it just stays on page 1.
Never go to another page.
That is the problem.
Here is my code:
code:
<html>
<head>
<title>Catalogue</title>
<link rel="stylesheet" type="text/css" href="../styles1/catalogue.css">
<link rel="stylesheet" type="text/css" href="../styles1/cata_menu.css">
</head>
<body>
<%'If Session("PW") ="" Then Response.Redirect("../login.htm")%>
<div id="menu">
<a href="Catalogue2a.asp?item=Collars"> Collars</a><br />
<a href="Catalogue2a.asp?item=Bracelets"> Bracelets</a><br />
<a href="Catalogue2a.asp?item=Bangles"> Bangles</a><br />
<a href="Catalogue2a.asp?item=Pendants"> Pendants </a><br />
<a href="Catalogue2a.asp?item=Earrings"> Earrings</a><br />
<a href="Catalogue2a.asp?item=Rings"> Rings</a><br />
<a href="Catalogue2a.asp?item=Necklace"> Chain/Necklaces</a><br />
<a href="Catalogue2a.asp?item=Designer"> Designer Pieces</a>
</div>
<%
' Declare our variables... always good practice!
Dim cnn ' ADO Connection
Dim rs ' ADO recordset
Dim x
Dim pg, psize,maxpages, maxrecs, recct,i
pg=Request("pg")
If pg = "" Then
pg = 1
End If
psize = Request("psize")
If psize = "" Then
psize = 7
End If
'this part decides what product is according to the choice of links
'if user come to this page, 'Collors' is the default.
Dim product
product = Request.QueryString("item")
If product="" then
product = "Collars"
else
product = Request.QueryString("item")
end if
ConnString = "Driver={Microsoft dBase Driver (*.dbf)}; DBQ =CATEGORY.dbf;DefaultDir=/home/sites/www.globalsilver.co.nz/web/LoginTest/DB"
Set cnn = Server.CreateObject("ADODB.Connection")
cnn.cursorlocation = 3
cnn.Open ConnString
'This is dynamic SQL
Set rs = cnn.Execute("SELECT * FROM CATEGORY WHERE CATEGORY='"&product&"'")
rs.pagesize = psize
maxpages = Int(rs.pagecount)
maxrecs = Int(rs.pagesize)
rs.absolutepage = pg
recct = 0
%>
<div id="catalogue">
<table align="center">
<tr><td style="font-size: 20px; color: #555;" colspan="3"><%=rs("CATEGORY").VALUE%></td><td colspan="3" align="right"><%Response.Write("Page" & pg & " of " & maxpages & "<br>")%></td></tr>
<%Do Until rs.EOF or recct >=maxrecs%>
<tr>
<% For each x in rs.Fields %>
<% 'For i = 0 to rs.Fields.count - 1%>
<%If x.name="CODE" Then%>
<td><img id="cat_bar" src="../assets/<%=product%>/<%Response.Write(x.value)%>"></td>
<%End If%>
<%If x.name <> "CATEGORY" Then%>
<td><% If x.name = "PRICE" Then Response.Write("$" & x.value) Else Response.Write(x.value) End IF %></td>
<%END IF%>
<%Next%>
<%rs.MoveNext
recct = recct + 1
%>
</tr>
<tr><td colspan="6"><img src="../assets/cat_bar.gif"></td></tr>
<%Loop%>
<tr><td align="center" colspan="6"><% If pg<>1 Then%>
<a class="page" href="Catalogue2a.asp?item=&product&?pg=<%=pg-1%> &psize=<%=psize%>">Previous</a>
<%End If%>
<%If pg-maxpages<>0 Then %>
<a class="page" href="Catalogue2a.asp?item=&product&?pg=<%=pg+1%> &psize=<%=psize%>"> Next</a>
<%End If%>
<%
Response.write("<br>")
'Not sure about this. Just doesn't work this page index
For i=1 to maxpages
Response.write("<a href=""Catalogue2.asp?item=" & product &"&?pg=" & i & """ >" & i & "</a> ")
Next
%> </td></tr>
</table>
<%Response.write(i)%>
<%
rs.Close
Set rs = Nothing
cnn.Close
Set cnn = Nothing
%>
</div>
</body>
</html>
Hmm....Do you seem something wrong?
I guess something wrong with:
code:
For i=1 to maxpages
Response.write("<a href=""Catalogue2.asp?item=" & product &"&?pg=" & i & """ >" & i & "</a> ")
Next
Hmm...
Hiroki Kozai