ho inserito una tabella con l interrogazione al db:
Pagina.asp completa:
si connette al db tramite:
cerca in tutti i record e campi, nella tabella Prodotti
Stampa a video tutti i Prodotti cercati:
http://www10.asphost4free.com/aspasp/catalogo.asp?scat=6
Se premete sul pulsante [Vai] sulla destra selezionando "Tutti i tipi" nella ricerca compare una tabella con i 4 record del db...
Vorrei che nei risultati della ricerca mi uscisse 1 record per ogni pagina e non 4..
e quando scorro con le pagine premendo su Successiva
mi uscissero gli altri 3 record che mancano..
ho fatto un po di confusione in questa parte di codice lo so.. :
con libro.movenext che si ripete anche con objRS.MoveNext, dovrei usarne solo uno di movenext.. chi mi dice dove inserirlo?.. ho fatto un po di prove ma non riesco a venirne a capo..
Codice:
<tr>
<td><font size="+1">Ricerca</font></td>
</tr>
<tr>
<td height="1" BGCOLOR="#999999"><img src="images/puntino_trasparente.gif" width="100%" height="1"></td>
</tr>
<%ricerca= Replace(request.form("ricerca"), "'", "''", 1, -1, 1)%>
<% if request.form("Prodotti")<>"" then%>
<tr>
<td height="3"><img src="images/puntino_trasparente.gif" width="1" height="5"></td>
</tr>
<%set libro=objConn.execute("select * from Prodotti where (Prodotto like '%"& ricerca &"%') or (PDescrizione like '%"& ricerca &"%')")%>
<tr>
<td><font size="1"><strong>Immobili:</strong></font></td>
</tr>
<%if libro.eof=false then
do while not libro.eof%>
<tr>
<td><font size="1"><strong><img src="images/freccia2.gif" width="4" height="6"> <a href="scheda.asp?id=<%=libro.fields("id")%>"><%=libro.fields("Prodotto")%></a></strong></font></td>
</tr>
<%libro.movenext
loop
else%>
<tr>
<td><font size="1"><strong>Nessun risultato trovato!</strong></font></td>
</tr>
<%end if%>
<tr>
<td height="3"><img src="images/puntino_trasparente.gif" width="1" height="5"></td>
</tr>
<tr>
<td height="1" BGCOLOR="#999999"><img src="images/puntino_trasparente.gif" width="100%" height="1"></td>
</tr>
<%libro.close
set libro=nothing%>
Pagina.asp completa:
Codice:
<% response.buffer=true %>
<% Server.ScriptTimeout = 300 %>
<!-- #include file="adovbs.inc"-->
<!-- #include file="connDb.asp"-->
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="200" valign="top"><table width="97%" border="0" cellspacing="0" cellpadding="0">
<form name="form2" method="post" action="newsletter.asp?action=mail" onsubmit="return winopen1(this)" target="click1"> <tr>
<td><font size="+1">Newsletter</font></td>
</tr>
<tr>
<td><font size="1">iscriviti alla nostra newsletter per essere informato periodicamente sulle novità della casa editrice.</font></td>
</tr>
<tr>
<td height="5"><img src="images/puntino_trasparente.gif" width="1" height="5"></td>
</tr>
<tr>
<td>
<input name="newsletter" id="searchfield" type="text" class="medium" size="20" onFocus="if( this.value==this.defaultValue ) this.value='';" value="e-mail" /style="BACKGROUND-COLOR: #E3DE4F; BORDER-BOTTOM: #525961 1px double; BORDER-LEFT: #32373C 1px double; BORDER-RIGHT: #525961 1px double; BORDER-TOP: #32373C 1px double; COLOR: #000000; FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif; FONT-SIZE: 11px; FONT-STYLE: normal; LINE-HEIGHT: normal">
<input type="submit" name="Submit" value="[VAI]" style="BACKGROUND-COLOR: #ffffff; BORDER-BOTTOM: #537db9 0px; BORDER-LEFT: #537db9 0px; BORDER-RIGHT: #537db9 0px; BORDER-TOP: #537db9 0px; COLOR: #000000; FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif; FONT-SIZE: 10px; FONT-STYLE: normal; LINE-HEIGHT: normal">
</td>
</tr>
</form>
<tr>
<td> </td>
</tr>
<form name="form1" method="post" onSubmit="return controllaRICERCA(this)" action="catalogo_ricerca.asp">
<tr>
<td><font size="+1">Ricerca nel sito</font></td>
</tr>
<tr>
<td><font size="1">inserisci i termini per la ricerca</font></td>
</tr>
<tr>
<td height="5"><img src="images/puntino_trasparente.gif" width="1" height="5"></td>
</tr>
<tr>
<td><font size="1">cerca in:</font></td>
</tr>
<tr>
<td><select name="Prodotti" >
<option value="Prodotti">Tutti i tipi</option>
<option value="Appartamento">Appartamenti</option>
<option value="Villa">Ville</option>
<option value="Rustico">Rustici</option>
</select>
<font size="1">Tipologia<br>
</font></td>
</tr>
<tr>
<td>
<input type="submit" name="Submit2" value="[VAI]" style="BACKGROUND-COLOR: #ffffff; BORDER-BOTTOM: #537db9 0px; BORDER-LEFT: #537db9 0px; BORDER-RIGHT: #537db9 0px; BORDER-TOP: #537db9 0px; COLOR: #000000; FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif; FONT-SIZE: 10px; FONT-STYLE: normal; LINE-HEIGHT: normal">
</td>
</tr>
</form>
</table>
<TABLE WIDTH="500" CELLPADDING="0" CELLSPACING="0" BORDER="0" align="center">
<TR height="60" valign="justify">
<TD align="justify">
<font face="verdana" size="2" color="#333333"> </font>
</TD>
<TR>
<TD>
<%
iPageSize = 1 'NUMERO RECORD PER PAGINA
If Request.QueryString("page") = "" Then
iPageCurrent = 1
Else
iPageCurrent = CInt(Request.QueryString("page"))
End If
strSQL = "SELECT * FROM Prodotti ORDER BY ID ASC"
Set objRS = Server.CreateObject("ADODB.Recordset")
objRS.PageSize = iPageSize
objRS.CacheSize = iPageSize
objRS.Open strSQL, objConn, adOpenStatic, adLockReadOnly, adCmdText
reccount = objRS.recordcount
iPageCount = objRS.PageCount
If iPageCurrent > iPageCount Then iPageCurrent = iPageCount
If iPageCurrent < 1 Then iPageCurrent = 1
If iPageCount = 0 Then
Response.Write "<p><b>Non sono stati trovati links.</b></p>"
Else
objRS.AbsolutePage = iPageCurrent
iRecordsShown = 0
%>
<table width="480" align="center" border="1" cellspacing="1" cellpadding="3">
<%
'SI VISUALIZZA IL CONTENUTO DELLA STRINGA SQL
'ALL'INTERNO DELLA TABELLA PRIMA DEFINITA
cont=1
Do While iRecordsShown < iPageSize And Not objRS.EOF
Dim Rig, bg
Rig = Rig + 1
If Rig Mod 2 = 0 then
bg = "#E4E4E4"
Else
bg = "#ccccff"
End if %>
<tr>
<td><font size="+1">Ricerca</font></td>
</tr>
<tr>
<td height="1" BGCOLOR="#999999"><img src="images/puntino_trasparente.gif" width="100%" height="1"></td>
</tr>
<%ricerca= Replace(request.form("ricerca"), "'", "''", 1, -1, 1)%>
<% if request.form("Prodotti")<>"" then%>
<tr>
<td height="3"><img src="images/puntino_trasparente.gif" width="1" height="5"></td>
</tr>
<%set libro=objConn.execute("select * from Prodotti where (Prodotto like '%"& ricerca &"%') or (PDescrizione like '%"& ricerca &"%')")%>
<tr>
<td><font size="1"><strong>Immobili:</strong></font></td>
</tr>
<%if libro.eof=false then
do while not libro.eof%>
<tr>
<td><font size="1"><strong><img src="images/freccia2.gif" width="4" height="6"> <a href="scheda.asp?id=<%=libro.fields("id")%>"><%=libro.fields("Prodotto")%></a></strong></font></td>
</tr>
<%libro.movenext
loop
else%>
<tr>
<td><font size="1"><strong>Nessun risultato trovato!</strong></font></td>
</tr>
<%end if%>
<tr>
<td height="3"><img src="images/puntino_trasparente.gif" width="1" height="5"></td>
</tr>
<tr>
<td height="1" BGCOLOR="#999999"><img src="images/puntino_trasparente.gif" width="100%" height="1"></td>
</tr>
<%libro.close
set libro=nothing%>
<%end if%>
<%
Cont = Cont + 1
'POSIZIONAMENTO ALLA RIGA SUCCESSIVA DEL DB
iRecordsShown = iRecordsShown + 1
objRS.MoveNext
Loop
'PULIZIA DEGLI OGGETTI ADO
objRS.Close
Set objRS = Nothing
%>
</table>
<%End if%>
<%If ipagecount <> 1 Then%>
<center><br>
<table>
<tr valign="middle">
<td width="50%" align="center" valign="middle"><font face="verdana" size="1" color="#000000">
<b><center>[
<%if iPageCurrent-2 > 0 and iPageCurrent > 2 then%>
<a href="catalogo_ricerca.asp?page=1">Prima</a>
<%end if%>
<%if iPageCurrent > 1 then%>
<a href="catalogo_ricerca.asp?page=<%=iPageCurrent-1%>">Precedente</a>
<%end if%>
<%if iPageCount > 2 then
if iPageCurrent-2 < 1 then da_pag = 1 else da_pag = iPageCurrent-2
if iPageCurrent+2 > iPageCount then fino_a_pag = iPageCount else fino_a_pag = iPageCurrent+2
else
da_pag = 1
fino_a_pag = iPageCount
end if%>
<%for i = da_pag to fino_a_pag%>
<%if i = iPageCurrent then%>
<font color="red"><%=i%></font>
<%else%>
<a href="catalogo_ricerca.asp?page=<%=i%>"><%=i%></a>
<%end if%>
<%next%>
<%if iPageCurrent > 0 and iPageCurrent < iPageCount then%>
<a href="catalogo_ricerca.asp?page=<%=iPageCurrent+1%>">Successiva</a>
<%end if%>
<%if iPageCurrent+1 < iPageCount then%>
<a href="catalogo_ricerca.asp?page=<%=iPageCount%>">Ultima</a>
<%end if%>
]</center></b>
</font></td>
</tr>
<tr>
<td colspan="2" align="center"><font face="verdana" size="0.5" color="#333333">
<center><br>
Pagina
<font color="#FF0000"><b><%=iPageCurrent%></b></font>
di
<font color="#FF0000"><b><%=iPageCount%></b></font>
</center>
</font></td>
</tr>
</table>
</center>
<%end if%>
<%
objConn.Close
Set objConn = Nothing
%>
</TD>
</TR>
</TABLE>
si connette al db tramite:
Codice:
<%set libro=objConn.execute("select * from Prodotti where (Prodotto like '%"& ricerca &"%') or (PDescrizione like '%"& ricerca &"%')")%>
cerca in tutti i record e campi, nella tabella Prodotti
Stampa a video tutti i Prodotti cercati:
Codice:
<%if libro.eof=false then
do while not libro.eof%>
http://www10.asphost4free.com/aspasp/catalogo.asp?scat=6
Se premete sul pulsante [Vai] sulla destra selezionando "Tutti i tipi" nella ricerca compare una tabella con i 4 record del db...
Vorrei che nei risultati della ricerca mi uscisse 1 record per ogni pagina e non 4..
e quando scorro con le pagine premendo su Successiva
mi uscissero gli altri 3 record che mancano..
ho fatto un po di confusione in questa parte di codice lo so.. :
Codice:
<%libro.movenext
loop
else%>
<tr>
<td><font size="1"><strong>Nessun risultato trovato!</strong></font></td>
</tr>
<%end if%>
<tr>
<td height="3"><img src="images/puntino_trasparente.gif" width="1" height="5"></td>
</tr>
<tr>
<td height="1" BGCOLOR="#999999"><img src="images/puntino_trasparente.gif" width="100%" height="1"></td>
</tr>
<%libro.close
set libro=nothing%>
con libro.movenext che si ripete anche con objRS.MoveNext, dovrei usarne solo uno di movenext.. chi mi dice dove inserirlo?.. ho fatto un po di prove ma non riesco a venirne a capo..
Ultima modifica: