Cliccate qui per accedere alla versione elettronica dei listati.
LISTATO 1
ELENCOFOTO.ASP
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "https://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Le foto di Mario Rossi</title>
</head>
<body>
<h1>Le mie foto preferite</h1>
<ul>
<%
Const adOpenForwardOnly = 0
Const adLockReadOnly = 1
Dim sql
Dim conn, rs
Set conn = Server.CreateObject "ADODB.Connection")
conn.Open "DRIVER=;DBQ=" & server.MapPath("/database/foto.mdb")
sql = "SELECT Titolo, Luogo FROM Foto"
Set rs = Server.CreateObject "ADODB.RecordSet")
rs.Open sql, conn, adOpenForwardOnly, adLockReadOnly
do until rs.eof
%>
<li><%=rs.Fields("Titolo")%>, scattata a <%=rs.Fields("Luogo")%></li>
<%
rs.movenext
loop
rs.close
set rs = nothing
conn.close
set conn = nothing
%>
</ul>
</body>
</html>
LISTATO 2
ELENCOFOTOLINK.ASP
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "https://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Le foto di Mario Rossi</title>
</head>
<body>
<h1>Le mie foto preferite</h1>
<%
Const adOpenForwardOnly = 0
Const adLockReadOnly = 1
Dim contatore
Dim sql1,sql2
Dim conn, rs
Set conn = Server.CreateObject "ADODB.Connection")
conn.Open "DRIVER=;DBQ=" & server.MapPath("/database/foto.mdb")
sql1 = "SELECT count(nome) AS contatore FROM Foto"
sql2 = "SELECT * FROM Foto ORDER BY Data DESC"
Set rs = Server.CreateObject "ADODB.RecordSet")
rs.Open sql1, conn, adOpenForwardOnly, adLockReadOnly
contatore = rs("contatore")
rs.Close
rs.Open sql2, conn, adOpenForwardOnly, adLockReadOnly
%>
Sono presenti <%=contatore%> foto <br><br>
<%
do until rs.eof
%>
<li><a href="dettagliofoto.asp?nome=<%=rs("Nome")%>"><%=rs("Titolo")%>, scattata a <%=rs("Luogo")%></a></li>
<%
rs.movenext
loop
'rs.close
'set rs = nothing
'conn.close
'set conn = nothing
%>
</ul>
</body>
</html>
LISTATO 3
RICERCA/RICERCA.ASP
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "https://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Le foto di Mario Rossi</title>
</head>
<body>
<h1>Cerca tra le mie foto preferite</h1>
<form action="elencofoto.asp" method="get">
Cerca la foto: <input type="text" name="rfoto"><br>
<input type="submit" value="Cerca">
</form>
</body>
</html>
LISTATO 4
RICERCA/ELENCOFOTO.ASP
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "https://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Le foto di Mario Rossi</title>
</head>
<body>
<h1>Le mie foto preferite</h1>
Hai selezionato le foto che parlano di <%=request.QueryString("rfoto")%><br>
<%
Const adOpenForwardOnly = 0
Const adLockReadOnly = 1
Dim contatore
Dim sql1,sql2
Dim conn, rs
Set conn = Server.CreateObject "ADODB.Connection")
conn.Open "DRIVER=;DBQ=" & server.MapPath("/database/foto.mdb")
sql1 = "SELECT count(nome) AS contatore FROM Foto WHERE Titolo like '%" & request.QueryString("rfoto") & "%'"
sql2 = "SELECT * FROM Foto WHERE Titolo like '%" & request.QueryString "rfoto") & "%' ORDER BY Data DESC "
Set rs = Server.CreateObject "ADODB.RecordSet")
rs.Open sql1, conn, adOpenForwardOnly, adLockReadOnly
contatore = rs("contatore")
rs.Close
rs.Open sql2, conn, adOpenForwardOnly, adLockReadOnly
%>
Sono presenti <%=contatore%> foto che soddisfano i criteri di ricerca<br><br>
<%
do until rs.eof
%>
<li><a href="dettagliofoto.asp?nome=<%=rs("Nome")%>"><%=rs("Titolo")%>, scattata a <%=rs("Luogo")%></a></li>
<%
rs.movenext
loop
'rs.close
'set rs = nothing
'conn.close
'set conn = nothing
%>
</ul>
</body>
</html>
|