MySQL Forums
Forum List  »  Italian

ASP è MYSQL - Paginazione forse problema LIMIT
Posted by: luigi amorfini
Date: August 11, 2007 03:12PM

Io ho una paginazione che ed è ambigua vedete la lista:
Perchè se metto 3 , mi mangia i record ed stampa 1 e 2 ma non fa vedere gli ultimi record
i record sono 8 nel db.

La tabella è cosi:

id : auto_increment
nome: varchar(255)
cognome: varchar(255)
residenza: varchar(255)
data: timestamp / sia insert e update.

codice:

pageSize = 10 - Visualizza Tutti i record.
pageSize = 8 - Visualizza Tutti i record. ed crea [1]
pageSize = 4 - Visualizza Tutti i record. ed crea [1] - [2]
pageSize = 3 - Visualizza solo 6 ed non 8. ed crea [1] - [2]

Il codice: è questo:
codice:
<!-- #include virtual ="/inc.asp" -->
<%
Set cn = Server.CreateObject("ADODB.Connection")
cn.Open "driver={MySQL ODBC 3.51 Driver};server=localhost;port=3306; uid=root;pwd=root;database=lab82;"

pageSize = 3

if(len(Request.QueryString("page"))=0)then
  currentPage = 1
else
  currentPage = CInt(Request.QueryString("page"))
end if

sql = "SELECT COUNT(*) AS CNT FROM dati"
set rs = cn.execute(sql)

recordCount = rs("CNT")
pageCount = int(CInt(recordCount) / pageSize)
rs.Close()

ord = trim(request("ord"))
if ord = "" then
ord = "uoat"
end if

 sql = "SELECT * FROM dati  LIMIT " & (currentPage - 1) * pageSize & ", " & pageSize


set rs = server.createObject("ADODB.Recordset")
rs.open sql, cn
if rs.eof then

   response.write "Nessun record"

   else
      While Not rs.eof

' stampa i records estratti
Response.Write("<br>" & rs("nome") & "")

  rs.MoveNext
      wend
end if

'Paginazione

if currentPage>1 then%>
<font face="Verdana" size="2">[ <b> <a href="?page=<%=CurrentPage-1%>">indietro</a></b> ]</font>
<%
end if
For x=1 to pageCount
%>
<font face="Verdana" size="2">[ <b> <a href="?page=<%=x%>"><%=x%></a></b> ]</font>
<%
next
if currentPage<pageCount then
%>
<font face="Verdana" size="2">[ <b> <a href="?page=<%=CurrentPage+1%>">avanti</a></b> ]</font>
<%
end if 



rs.close
cn.Close

set rs = nothing
set cn = Nothing

%>

Non da nessuno errore: ho stampato anche la query è la query è cosi:

SELECT * FROM dati LIMIT 0, 3

come mai?

grazie....



Edited 1 time(s). Last edit at 08/11/2007 03:13PM by luigi amorfini.

Options: ReplyQuote


Subject
Views
Written By
Posted
ASP è MYSQL - Paginazione forse problema LIMIT
7585
August 11, 2007 03:12PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.