ho inserito una tabella con l interrogazione al db:
Pagina.asp completa:codice:<tr> <td><font size="+1">Ricerca</font></td> </tr> <tr> <td height="1" BGCOLOR="#999999">[img]images/puntino_trasparente.gif[/img]</td> </tr> <%ricerca= Replace(request.form("ricerca"), "'", "''", 1, -1, 1)%> <% if request.form("Prodotti")<>"" then%> <tr> <td height="3">[img]images/puntino_trasparente.gif[/img]</td> </tr> <%set libro=objConn.execute("select * from Prodotti where (Prodotto like '%"& ricerca &"%') or (PDescrizione like '%"& ricerca &"%')")%> <tr> <td><font size="1">Immobili:</font></td> </tr> <%if libro.eof=false then do while not libro.eof%> <tr> <td><font size="1">[img]images/freccia2.gif[/img] "><%=libro.fields("Prodotto")%></font></td> </tr> <%libro.movenext loop else%> <tr> <td><font size="1">Nessun risultato trovato!</font></td> </tr> <%end if%> <tr> <td height="3">[img]images/puntino_trasparente.gif[/img]</td> </tr> <tr> <td height="1" BGCOLOR="#999999">[img]images/puntino_trasparente.gif[/img]</td> </tr> <%libro.close set libro=nothing%>
codice:<% response.buffer=true %> <% Server.ScriptTimeout = 300 %> <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]images/puntino_trasparente.gif[/img]</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]images/puntino_trasparente.gif[/img]</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 </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 " Non sono stati trovati links.</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]images/puntino_trasparente.gif[/img]</td> </tr> <%ricerca= Replace(request.form("ricerca"), "'", "''", 1, -1, 1)%> <% if request.form("Prodotti")<>"" then%> <tr> <td height="3">[img]images/puntino_trasparente.gif[/img]</td> </tr> <%set libro=objConn.execute("select * from Prodotti where (Prodotto like '%"& ricerca &"%') or (PDescrizione like '%"& ricerca &"%')")%> <tr> <td><font size="1">Immobili:</font></td> </tr> <%if libro.eof=false then do while not libro.eof%> <tr> <td><font size="1">[img]images/freccia2.gif[/img] "><%=libro.fields("Prodotto")%></font></td> </tr> <%libro.movenext loop else%> <tr> <td><font size="1">Nessun risultato trovato!</font></td> </tr> <%end if%> <tr> <td height="3">[img]images/puntino_trasparente.gif[/img]</td> </tr> <tr> <td height="1" BGCOLOR="#999999">[img]images/puntino_trasparente.gif[/img]</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> <table> <tr valign="middle"> <td width="50%" align="center" valign="middle"><font face="verdana" size="1" color="#000000"> <center>[ <%if iPageCurrent-2 > 0 and iPageCurrent > 2 then%> Prima <%end if%> <%if iPageCurrent > 1 then%> Precedente <%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%> <%=i%> <%end if%> <%next%> <%if iPageCurrent > 0 and iPageCurrent < iPageCount then%> Successiva <%end if%> <%if iPageCurrent+1 < iPageCount then%> Ultima <%end if%> ]</center> </font></td> </tr> <tr> <td colspan="2" align="center"><font face="verdana" size="0.5" color="#333333"> <center> Pagina <font color="#FF0000"><%=iPageCurrent%></font> di <font color="#FF0000"><%=iPageCount%></font> </center> </font></td> </tr> </table> </center> <%end if%> <% objConn.Close Set objConn = Nothing %> </TD> </TR> </TABLE>
si connette al db tramite:
cerca in tutti i record e campi, nella tabella Prodotticodice:<%set libro=objConn.execute("select * from Prodotti where (Prodotto like '%"& ricerca &"%') or (PDescrizione like '%"& ricerca &"%')")%>
Stampa a video tutti i Prodotti cercati:
http://www10.asphost4free.com/aspasp...ogo.asp?scat=6codice:<%if libro.eof=false then do while not libro.eof%>
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:<%libro.movenext loop else%> <tr> <td><font size="1">Nessun risultato trovato!</font></td> </tr> <%end if%> <tr> <td height="3">[img]images/puntino_trasparente.gif[/img]</td> </tr> <tr> <td height="1" BGCOLOR="#999999">[img]images/puntino_trasparente.gif[/img]</td> </tr> <%libro.close set libro=nothing%>

Rispondi quotando

