Buongiorno,
Io ho un database che contiene una serie di dati dei vari utenti registrati (nome, cognome, età, ecc.)
Ho creato una pagina che mi legge questi dati, ma che li legge tutti.
Se io volessi estrapolare gli utenti nati in un determinato anno, tipo 1980. come faccio?
Posto il codice che mi legge i dati
---------------------
<%
Dim conn
Dim iPageSize
Dim iPageCount
Dim iPageCurrent
Dim strOrderBy
Dim strSQL
Dim RS
Dim iRecordsShown
iPageSize = 20
If Request.QueryString("page") = "" Then
iPageCurrent = 1
Else
iPageCurrent = CInt(Request.QueryString("page"))
End If
If Request.QueryString("order") = "" Then
strOrderBy = "id"
Else
strOrderBy = Request.QueryString("order")
End If
Set Conn = Server.CreateObject("ADODB.Connection")
conn.Open "driver={Microsoft Access Driver (*.mdb)};dbq=" & server.mappath("../database/dbdisconotte.mdb")
Set RS = Server.CreateObject("ADODB.Recordset")
sql = "SELECT * FROM rec_utenti ORDER BY " & strOrderBy & " DESC;"
RS.Open sql, conn, adOpenKeyset
RS.PageSize = iPageSize
RS.CacheSize = iPageSize
iPageCount = RS.PageCount
If iPageCurrent > iPageCount Then iPageCurrent = iPageCount
If iPageCurrent < 1 Then iPageCurrent = 1
If iPageCount = 0 Then
Response.Write("NESSUN UTENTE REGISTRATO!")
Else
RS.AbsolutePage = iPageCurrent
iRecordsShown = 0
Do While iRecordsShown < iPageSize And Not RS.EOF
%>
<div align="left">
<table border="0" cellpadding="0" cellspacing="0" width="1246" style="border-collapse: collapse" bordercolor="#111111" height="39">
<tr>
<td width="28" style="border-right:1px solid #FFFFFF; border-left:1px solid #FFFFFF; border-top:1px solid #000080; " align="center" bgcolor="#000080" height="20">
</td>
<td width="28" style="border-right:1px solid #FFFFFF; border-left:1px solid #FFFFFF; border-top:1px solid #000080; " align="center" bgcolor="#000080" height="20">
</td>
<td width="28" style="border-right:1px solid #FFFFFF; border-left:1px solid #FFFFFF; border-top:1px solid #000080; " align="center" bgcolor="#000080" height="20">
</td>
<td width="86" style="border-right:1px solid #FFFFFF; border-left:1px solid #FFFFFF; border-top:1px solid #000080; " align="center" bgcolor="#000080" height="20">
<font face="Verdana" color="#FFFFFF">N.</font><font color="#FFFFFF"> </font>
</td>
<td width="99" style="border-left: 1px solid #FFFFFF; border-right: 1px solid #FFFFFF; border-top: 1px solid #000080; " align="center" bgcolor="#000080" height="20">
<font face="Verdana" color="#FFFFFF">DATA</font><font color="#FFFFFF">
</font>
</td>
<td width="234" style="border-left:1px solid #FFFFFF; border-right:1px solid #FFFFFF; border-top:1px solid #000080; " align="center" bgcolor="#000080" height="20">
<font face="Verdana" color="#FFFFFF">NOME</font><font color="#FFFFFF">
</font>
</td>
<td width="182" style="border-left:1px solid #FFFFFF; border-right:1px solid #FFFFFF; border-top:1px solid #000080; " align="center" bgcolor="#000080" height="20">
<font face="Verdana" color="#FFFFFF">COGNOME</font><font color="#FFFFFF">
</font>
</td>
<td width="42" style="border-left:1px solid #FFFFFF; border-right:1px solid #FFFFFF; border-top:1px solid #000080; " align="center" bgcolor="#000080" height="20">
<font face="Verdana" color="#FFFFFF">SESSO</font><font color="#FFFFFF">
</font>
</td>
<td width="24" style="border-left:1px solid #FFFFFF; border-right:1px solid #FFFFFF; border-top:1px solid #000080; " align="center" bgcolor="#000080" height="20">
<font face="Verdana" color="#FFFFFF">GG </font>
</td>
<td width="24" style="border-left:1px solid #FFFFFF; border-right:1px solid #FFFFFF; border-top:1px solid #000080; " align="center" bgcolor="#000080" height="20">
<font face="Verdana" color="#FFFFFF">MM</font></td>
<td width="41" style="border-left:1px solid #FFFFFF; border-right:1px solid #FFFFFF; border-top:1px solid #000080; " align="center" bgcolor="#000080" height="20">
<font face="Verdana" color="#FFFFFF">ANNO</font></td>
<td width="234" style="border-left:1px solid #FFFFFF; border-right:1px solid #FFFFFF; border-top:1px solid #000080; " align="center" bgcolor="#000080" height="20">
<font face="Verdana" color="#FFFFFF">INDIRIZZO</font><font color="#FFFFFF">
</font>
</td>
<td width="29" style="border-left:1px solid #FFFFFF; border-right:1px solid #FFFFFF; border-top:1px solid #000080; " align="center" bgcolor="#000080" height="20">
<font face="Verdana" color="#FFFFFF">N.</font><font color="#FFFFFF">
</font>
</td>
<td width="299" style="border-left:1px solid #FFFFFF; border-right:1px solid #FFFFFF; border-top:1px solid #000080; " align="center" bgcolor="#000080" height="20">
<font face="Verdana" color="#FFFFFF">COMUNE</font><font color="#FFFFFF">
</font>
</td>
<td width="55" style="border-left:1px solid #FFFFFF; border-right:1px solid #FFFFFF; border-top:1px solid #000080; " align="center" bgcolor="#000080" height="20">
<font face="Verdana" color="#FFFFFF">CAP</font><font color="#FFFFFF">
</font>
</td>
<td width="59" style="border-left:1px solid #FFFFFF; border-right:1px solid #FFFFFF; border-top:1px solid #000080; " align="center" bgcolor="#000080" height="20">
<font color="#FFFFFF" face="Verdana">PROVINCIA</font></td>
<td width="149" style="border-left:1px solid #FFFFFF; border-right:1px solid #FFFFFF; border-top:1px solid #000080; " align="center" bgcolor="#000080" height="20">
<font face="Verdana" color="#FFFFFF">CELLULARE</font></td>
<td width="257" style="border-left:1px solid #FFFFFF; border-right:1px solid #FFFFFF; border-top:1px solid #000080; " align="center" bgcolor="#000080" height="20">
<font face="Verdana" color="#FFFFFF">EMAIL</font></td>
</tr>
<tr>
<td width="18" style="border-left: 1px solid #000080; border-top: 1px solid #000080; border-bottom: 1px solid #000080; " height="19" valign="middle">
<p align="center">
">[img]cancella.gif[/img]
</td>
<td width="18" style="border-left: 1px solid #000080; border-top: 1px solid #000080; border-bottom: 1px solid #000080; " height="19" valign="middle">
<p align="center">
">[img]modifica.gif[/img]
</p>
</td>
<td width="27" style="border-left: 1px solid #000080; border-top: 1px solid #000080; border-bottom: 1px solid #000080; " height="19" valign="middle">
<p align="center">
<a style="text-decoration: none" href="invio_mail_riduzioni.asp?cod=<%=rs("id")%>">
[img]email.jpg[/img]</a></td>
<td width="86" style="border-left: 1px solid #000080; border-top: 1px solid #000080; border-bottom: 1px solid #000080; " height="19">
<p align="center"><font face="Verdana" style="font-size: 8pt"><% response.write(rs("id"))%>
</font>
</td>
<td width="99" style="border: 1px solid #000080; " height="19">
<font face="Verdana" style="font-size: 8pt"><% response.write(rs("iscrizione"))%>
</font>
</td>
<td width="234" style="border-right: 1px solid #000080; border-top: 1px solid #000080; border-bottom: 1px solid #000080; " height="19">
<font face="Verdana" style="font-size: 8pt"><% response.write(rs("nome"))%>
</font>
</td>
<td width="182" style="border-right: 1px solid #000080; border-top: 1px solid #000080; border-bottom: 1px solid #000080; " height="19">
<font face="Verdana" style="font-size: 8pt"><% response.write(rs("cognome"))%>
</font>
</td>
<td width="42" style="border-right: 1px solid #000080; border-top: 1px solid #000080; border-bottom: 1px solid #000080; " height="19">
<p align="center">
<font face="Verdana" style="font-size: 8pt"><% response.write(rs("sesso"))%>
</font>
</td>
<td width="24" style="border-right: 1px solid #000080; border-top: 1px solid #000080; border-bottom: 1px solid #000080; " height="19">
<font face="Verdana" style="font-size: 8pt"><% response.write(rs("gg"))%>
</font>
</td>
<td width="24" style="border-right: 1px solid #000080; border-top: 1px solid #000080; border-bottom: 1px solid #000080; " height="19">
<font face="Verdana" style="font-size: 8pt"><% response.write(rs("mm"))%>
</font>
</td>
<td width="41" style="border-right: 1px solid #000080; border-top: 1px solid #000080; border-bottom: 1px solid #000080; " height="19">
<font face="Verdana" style="font-size: 8pt"><% response.write(rs("anno"))%>
</font>
</td>
<td width="234" style="border-right: 1px solid #000080; border-top: 1px solid #000080; border-bottom: 1px solid #000080; " height="19">
<font face="Verdana" style="font-size: 8pt"><% response.write(rs("indirizzo"))%>
</font>
</td>
<td width="29" style="border-right: 1px solid #000080; border-top: 1px solid #000080; border-bottom: 1px solid #000080; " height="19">
<font face="Verdana" style="font-size: 8pt"><% response.write(rs("ncivico"))%>
</font>
</td>
<td width="299" style="border-right: 1px solid #000080; border-top: 1px solid #000080; border-bottom: 1px solid #000080; " height="19">
<font face="Verdana" style="font-size: 8pt"><% response.write(rs("comune"))%>
</font>
</td>
<td width="55" style="border-right: 1px solid #000080; border-top: 1px solid #000080; border-bottom: 1px solid #000080; " height="19">
<font face="Verdana" style="font-size: 8pt"><% response.write(rs("cap"))%>
</font>
</td>
<td width="59" style="border-right: 1px solid #000080; border-top: 1px solid #000080; border-bottom: 1px solid #000080; " height="19">
<p align="center"><% response.write(rs("provincia"))%>
</td>
<td width="149" style="border-right: 1px solid #000080; border-top: 1px solid #000080; border-bottom: 1px solid #000080; " height="19">
<p align="center"><font face="Verdana" style="font-size: 8pt"><% response.write(rs("cellulare"))%>
</font>
</td>
<td width="257" style="border-right: 1px solid #000080; border-top: 1px solid #000080; border-bottom: 1px solid #000080; " height="19">
<p align="center"><% response.write(rs("email"))%>
</td>
</tr>
</table>
</div>
</p>
<p align="center">
<%
iRecordsShown = iRecordsShown + 1
RS.MoveNext
Loop
RS.Close
Set RS = Nothing
Conn.Close %>
<%
If iPageCurrent <> 1 Then
%>
<div align="center">
<center>
<table border="0" cellpadding="0" cellspacing="0" width="1000">
<tr>
<td width="161">
<font face="Verdana">
Indietro</font>
<%
End If
%>
<%
If iPageCurrent < iPageCount Then
%> <font face="Verdana">
<a href="elenco_riduzioni.asp?page=<%= iPageCurrent + 1 %>&order=<%= Server.URLEncode(strOrderBy) %>">Avanti
</a>
</font>
</td>
<td width="739">
<p align="right"><font face="Verdana" color="#000080"><a href="admin.asp">TORNA
ADMIN</a></font><a href="admin.asp"><%
End If
%
-----------------------------------------------------
Grazie

Rispondi quotando