Perdono.... ecco lo script completo:
Graziecodice:<% scategoria = Request.querystring("cat") if scategoria="tutte" then scategoria = "%" dim currentPage, pageSize, recordCount, pageCount pageSize = 3 if(len(Request.QueryString("page"))=0)then currentPage = 1 else currentPage = CInt(Request.QueryString("page")) end if dim conn, rs, sql Set Conn=Server.CreateObject("ADODB.Connection") Conn.Open "DRIVER={MySQL ODBC 3.51 Driver};SERVER=00.111.222.333;DATABASE=Sql123456_1;UID=Sql123456;PASSWORD=abcdefgh" sql = "SELECT COUNT(*) AS CNT FROM (SELECT id, cosa, titolo, testo, foto, categoria, data, attiva from foto WHERE categoria = '"& scategoria &"' AND attiva = 'SI' UNION ALL SELECT id, cosa, titolo, testo, video, categoria, data, attiva from video WHERE categoria = '"& scategoria &"' AND attiva = 'SI') AS TOTAL order by data desc" set rs = conn.execute(sql) recordCount = rs("CNT") pageCount = int(CInt(recordCount) / pageSize) rs.Close() ' seleziona i record da visualizzare nella pagina corrente sql = "SELECT * FROM (SELECT id, cosa, titolo, testo, foto, categoria, data, attiva from foto WHERE categoria = '"& scategoria &"' AND attiva = 'SI' UNION ALL SELECT id, cosa, titolo, testo, video, categoria, data, attiva from video WHERE categoria = '"& scategoria &"' AND attiva = 'SI') AS TOTAL " &_ " order by data desc LIMIT " & (currentPage - 1) * pageSize & ", " & pageSize set rs = conn.execute(sql) Dim rcount, i, x For i = 1 To rs.PageSize rcount = i If page > 1 Then For x = 1 To (page - 1) rcount = rcount Next End If If Not rs.EOF Then %> RISULTATI <% rs.MoveNext End If Next rs.Close() set rs = nothing conn.Close() set conn = nothing For page = 1 to pageCount Response.Write "<A href='"&istring&"?page="&page Response.Write "&cat="&request.querystring("cat") Response.write "'>" Response.write "<font size=2 color=#000080>" Response.Write page Response.Write "</A> - " Next Response.Write "" %>
G.

Rispondi quotando