Pagina 1 di 4 1 2 3 ... ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 39

Discussione: ricerca + paginazione

  1. #1
    Utente di HTML.it L'avatar di Lino80
    Registrato dal
    Oct 2005
    Messaggi
    1,560

    ricerca + paginazione

    ho inserito una tabella con l interrogazione al db:

    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%>
    Pagina.asp completa:

    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&agrave; 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:

    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...ogo.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">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%>
    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..

  2. #2
    Utente di HTML.it L'avatar di Sypher
    Registrato dal
    Jun 2003
    Messaggi
    1,994
    oddio nn ho letto tutto il codice...comunque se può esserti utile c'è il metodo Move del recordset che ti permette...dopo aver eseguito la select di spostarti come ti pare sui record

    per esempio objRs.Move 2 si posiziona sul secondo record
    La passera non dura perchè Sypher la cattura!

    "No one like us we don't care, we are millwall, super millwall, we are millwall from the DEN"

  3. #3
    Utente di HTML.it L'avatar di Lino80
    Registrato dal
    Oct 2005
    Messaggi
    1,560
    ho impostato:

    codice:
    <%libro.move 2
    			  loop
    			  else%>
    ora se fai la ricerca visualizza solo 2 record, il primo e il terzo.. e rimane il problema delle pagine successive..

  4. #4
    Utente di HTML.it L'avatar di Lino80
    Registrato dal
    Oct 2005
    Messaggi
    1,560
    up!

  5. #5
    Utente di HTML.it L'avatar di Lino80
    Registrato dal
    Oct 2005
    Messaggi
    1,560
    nessun esperto può perdere un pochino di tempo per vedere il codice per me? posso pagare anche per essere aiutato..basta che mi dite quanto volete..

    grazie

  6. #6
    Utente di HTML.it L'avatar di Lino80
    Registrato dal
    Oct 2005
    Messaggi
    1,560
    ho provato ad inserire 5 record e me ne visualizza 5 risultati... ma sempre nella stessa pagina...

    http://www10.asphost4free.com/aspasp...ogo.asp?scat=6

  7. #7
    Utente di HTML.it L'avatar di Lino80
    Registrato dal
    Oct 2005
    Messaggi
    1,560
    up

  8. #8
    Utente di HTML.it L'avatar di Lino80
    Registrato dal
    Oct 2005
    Messaggi
    1,560
    uppete, anima gentile

  9. #9
    Utente di HTML.it L'avatar di Sandra
    Registrato dal
    May 2005
    Messaggi
    129

    ricerca + paginazione

    Se vuoi risolvere il tuo problema ti consiglio una bella ricerca sul forum, trovi tanti post che parla di paginazione e ricerca.

    Ciao.

  10. #10
    Utente di HTML.it L'avatar di Lino80
    Registrato dal
    Oct 2005
    Messaggi
    1,560
    grazie.. farò una ricerca..

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2026 vBulletin Solutions, Inc. All rights reserved.