domanda semplice per ricerca nel db

sara80

Nuovo Utente
21 Mag 2007
24
0
0
ciao, sto creando un piccolo form per la ricerca nel db, chi mi da un aiutino? :p mi da pagina bianca quando faccio la ricerca..

mi sa che devo modificare la parte di codice riguardante le query, SQL = SQL & " ecc ecc.. vero?

il mio db è così strutturato: http://www10.asphost4free.com/aspasp/db.jpg

il form per la ricerca è:

Codice:
<form action="include/inc_catalogo_cerca_imm.asp" method="post" name="cerca" id="cerca" style="width: 135px; padding: 0px; margin: 0px auto;">
<p><strong>   Tipologia:</strong><br />
<select name="Prodotto" >
<option value="Prodotto">Tutti i tipi</option>
<option value="Appartamento">Appartamenti</option>
<option value="Villa">Ville</option>
<option value="Rustico">Rustici</option>
</select>
</p>
<p><strong>  Località:</strong><br />
<select name="PDescrizione" >
<option value="PDescrizione">Tutte le località</option>
<option value="Gravedona">Gravedona</option>
<option value="Pianello">Pianello</option>
<option value="Menaggio">Menaggio</option>
</select>
</p>
<p><strong>  Prezzo:</strong><br />
<select name="CPrezzo" >
<option value="CPrezzo">Tutti i prezzi</option>
<option value="10000000">Fino a 120.000 euro</option>
<option value="15000000">Da 120.000 a 200.000</option>
<option value="20000000">Da 200.000 a 300.000</option>
<option value="25000000">Da 300.000 a 500.000</option>
<option value="50000000">Oltre 500.000</option>
</select>
</p>
<p>
<label>
<input name="Submit" type="submit" class="submit" value="Cerca Immobile" />
</label>
</p>
</form>

la pagina dove stampa i risultati è:

Codice:
<%
'---Dichiarazione variabili
	Dim SQL, RS, I, Footer, RStip, Index, ArrQuery

	If (QSSCategoria <> "") Or (QSQuery <> "") Then
		 Dim smSQLCat, smRSCat, smscat, smcat, smdovesei
		 
		 if QSSCategoria <>"" then
		 		smSQLCat = " SELECT ID, SCategoria FROM SCategorie where ID="&Cint(QSSCategoria)
				smscat=""
				Set smRScat = Conn.Execute(smSQLCat)
				If Not smRSCat.EOF Then
					 smscat=smRScat("Scategoria")
				end if
				smRSCat.close	
			end if	
			
			if QSCategoria <>"" then
				 smSQLCat = " SELECT * FROM Categorie  where ID="&Cint(QSCategoria)
				 smcat=""
				 Set smRScat = Conn.Execute(smSQLCat)
				 If Not smRSCat.EOF Then
				 		smcat=smRScat("Categoria")
				 end if
			smRSCat.close	
			end if
					
			smdovesei="Hai selezionato il pulsante"
			
			if smscat<>"" then
				 smdovesei=smdovesei&": <a href=""catalogo.asp?scat="&QSSCategoria&""">"&smscat&"</a>"
			end if
			
			if smcat<>"" then
				 smdovesei=smdovesei&" , <a href=""catalogo.asp?scat="&QSSCategoria&"&cat="&QSCategoria&""">"&smcat&"</a>"
			end if
			
			response.write(smdovesei)		
	 
%>
</font></b><font size="3"> </font>

	<p align="justify">
		<%=Head_Catalogo%>    
	<p align="justify">
  
	<!--Inserimento sottocategorie colonna centrale-->
  
	<table width="100%" border="0" cellspacing="0" cellpadding="3" bordercolordark="#E5E5E5" bordercolorlight="#000000" border="1">
<tr><td bgcolor="<%=Tabella_Colore_Cella%>" align="justify">
				

      <%
	SQLCat = " SELECT ID, SCategoria FROM SCategorie "
	Set RScat = Conn.Execute(SQLCat)

	If Not RSCat.EOF Then
		SCatArr = RScat.GetRows

'---Stampo a video le scategorie ed eventuali categorie
		If QSSCategoria <> "" Then
			SQLCat = " SELECT ID, Categoria FROM Categorie WHERE SCategoria = " & QSSCategoria
			Set RSCat = Conn.Execute(SQLCat)

			If Not RSCat.EOF Then 
				CatArr = RSCat.GetRows
				BoolCategorie = True
			Else
				BoolCategorie = False
			End If

			RSCat.Close
		End If

		For Icat = 0 to UBound(SCatArr, 2)
%>
     
      <%
			If CStr(SCatArr(0,ICat)) = QSSCategoria Then
				If boolCategorie Then
					For K = 0 To UBound(CatArr,2)
%>
      <img src="<%=Path_Img%>catalogo_frecciadx.gif" width="7" height="9" border="0"> 
      </font> 
      <a href="catalogo.asp?scat=<%=SCatArr(0,ICat)%>&cat=<%=CatArr(0,k)%>">
		<%=CatArr(1,k)%></font></a><font color="#000080"> 
      
      <%
					Next
				End If
			End If
		Next
	Else
%>
      <%=NoCategoria%> <br> 
      <%
	End If
%>
			</font>
			</td>
			</table>
<br>
<!--Fine inserimento sottocategorie colonna centrale-->	
	</p>
	<table border="1" width="500" cellspacing="0" cellpadding="3" align="center">
		<tr> 
			<td width="135" bgcolor="<%=Tabella_Colore_Titolo%>">
				<b><%=TitoloProdotto%></b>
			</td>
			<td bgcolor="<%=Tabella_Colore_Titolo%>">
				<b><%=TitoloPFoto%></b>
			</td>
			<td width="130" bgcolor="<%=Tabella_Colore_Titolo%>">
				<b><%=TitoloPDescrizione%></b>
			</td>
			<td width="100" bgcolor="<%=Tabella_Colore_Titolo%>">
				<b><%=TitoloCPrezzo%></b>
			</td>
			<td width="50" bgcolor="<%=Tabella_Colore_Titolo%>">
				<b><%=TitoloPulsante%></b>
			</td>
		</tr>
<%
		If (QSSCategoria = "") AND (QSCategoria = "") AND (QSQuery = "") Then
			Response.Redirect Request.ServerVariables("HTTP_REFERER")
		Else
'---Stampo a video i prodotti delle categorie richieste
			Set RS = Server.CreateObject("ADODB.RecordSet")
			RS.PageSize = MaxProdottiPerPagina
			
			If QSQuery <> "" Then
				QSQuery = Replace(QSQuery, "'", "''")
				ArrQuery = Split(QSQuery, " ")
				SQL = " SELECT * FROM Prodotti WHERE "
				For i = 0 to UBound(ArrQuery, 1)
					SQL = SQL & "(Prodotto LIKE '%" & ArrQuery(i) & "%' OR PDescrizione LIKE '%" & ArrQuery(i) & "%' OR GDescrizione LIKE '%" & ArrQuery(i) & "%') AND "
				Next
				SQL = SQL & "Cancellato = False"
				RS.Open SQL, Conn, 1
			Else
				If (QSCategoria = "") Then
					SQL = " SELECT * FROM Prodotti WHERE SCategoria = "& [QSSCategoria] &" AND Categoria = 0  AND Cancellato = False "
					RS.Open SQL, Conn, 1
				End If
	
				If (QSCategoria <> "") Then
					SQL = " SELECT * FROM Prodotti WHERE Categoria = "& [QSCategoria] &" AND Cancellato = False"
					RS.Open SQL, Conn, 1
				End If
			End If

			If Not RS.EoF Then 
				RS.MoveFirst
				RS.AbsolutePage = QSPg

				If QSPg <> 1 Then
					Footer = "<a href=""catalogo.asp?scat=" & QSSCategoria & "&cat=" & QSCategoria & "&pg=1&q=" & QSQuery & """>" & PrimaPagina & "</a> "
				Else
					Footer = PrimaPagina & " "
				End If

				For I = 1 To RS.PageCount
					If I = QSPg Then
						Footer = Footer & I & " "
					Else
						Footer = Footer & "<a href=""catalogo.asp?scat="&QSSCategoria&"&cat="&QSCategoria&"&pg="&i&"&q=" & QSQuery & """>"& I &"</a> "
					End If
				Next

				If QSPg <> RS.PageCount Then
					Footer = Footer & "<a href=""catalogo.asp?scat="&QSSCategoria&"&cat="&QSCategoria&"&pg="&RS.PageCount&"&q=" & QSQuery & """>" & UltimaPagina & "</a>"
				Else
					Footer = Footer & UltimaPagina
				End If

				For I = 1 To RS.PageSize
					If RS.EOF Then Exit For
%>
		<tr bgcolor="<%=Tabella_Colore_Cella%>">
			<form method="get" action="prod_aggiungi.asp">
				<td bgcolor="<%=Tabella_Colore_Cella%>" width="135" valign="top">
<%
					If RS("Offerta") = True Then
%>
					
<%
					End If
					If StrToData(RS("Data")) > (Date - GiorniNovita) Then
%>
				
<%
					End If
%>
					
					<p align="center">
					<b>Apri scheda Prodotto:					</b></p>
					<p align="center"><b><a href="scheda.asp?id=<%=RS("ID")%>"><%=RS("Prodotto")%></a>
                    <%	    
					If  RS("Tipologia") = True Then
%>
				    </b>
				  </p>
					<p align="center">
<%
						Set RStip = Server.CreateObject("ADODB.RecordSet")
						SQL = " SELECT * FROM Tipologie WHERE IDProdotto = "& RS("ID")

						With RStip
							.Open SQL, Conn, 1
							If Not (.BOF And .EOF) Then
%>
						<select name="Tipologia">
<%
								Index = 1
								Do While Not .EOF
									If Index = 1 Then
%>
							<option Selected value='<%=.Collect("ID")%>'><%=.Collect("Tipologia")%>
<%
									Else
%>
							<option value='<%=.Collect("ID")%>'><%=.Collect("Tipologia")%>
<%
									End If

									Index = Index + 1
									.MoveNext
								Loop
							End If

							.Close
						End With

    						Set RStip = Nothing
%>           
						</select>
					</p>
<%
					End If
%>
				</td>
				<td align="center">
					<a href="scheda.asp?id=<%=RS("ID")%>"><%dim prodotto%>
<%Prodotto=RS("Prodotto")%><img src="../
<%
					If RS("PFoto") <> ("public/imgprodotti/") Then
						Response.Write RS("PFoto")
					Else
						Response.Write  Img_NonDisponibile_P
					End If
%>
					" alt="<%=Prodotto%>" width="<%=PFoto_Larghezza%>" height="<%=PFoto_Altezza%>" border="0">
				</td>
				<td width="130" valign="top" bgcolor="#FFFFFF">
					<p align="left">
					<br>
					<%=RS("PDescrizione")%>
					<br>
					<%If UtilizzaPrezzo(RS("PuntiSconto")) > 0 Then%><br><%=PuntiUsabili%>: <%=VisualizzaPrezzo(RS("PuntiSconto"))%><%End If%>
				</td>
				<td width="100" valign="top">
					<br><b><%=SimboloValuta%></b> <%=VisualizzaPrezzo(RS("CPrezzo"))%>
<%
					If Session("Rivenditore") = False Then
%>
					<br>
					<br>
<%
					End If
%>
					
				</td>
				<td width="50" align="center">
					Quantità:<input type="text" name="quantita" size="2" maxlength="5" value="1">
					<input type="hidden" name="ID" value="<%=RS("ID")%>">
<%
					If (RS("Giacenza") > 0) OR RS("GiacenzaInfinita") Then
%>
					

<%
					Else
%>
					
					<br>
					<a href="scrivi_prenotazione.asp?id=<%=RS("ID")%>">Prenotalo ora!</a></p>
					<br>
<%
					End If
%>
				</td>
				
			</form>
		</tr>
<%
					RS.MoveNext
				Next
			Else
%>
		<tr bgcolor="<%=Tabella_Colore_Cella%>"> 
			<td colspan="5" align="center" height="18">
				
				<%=NoRecordTrovati%>
			</td>
		</tr>
<%
			End If
		End If
		RS.Close
%>
	</table>
<%
	End If
%>
	<div align="center">
		<br>
        	<%=Footer%>
  </div>
 

sara80

Nuovo Utente
21 Mag 2007
24
0
0
chi mi può dare una mano?mi servirebbe per un esame domani mattina :(

grazie
 

sara80

Nuovo Utente
21 Mag 2007
24
0
0
se cerco "Appartamenti" con questo form mi trova i risultati:

Codice:
<form action="cerca_catalogo.asp" method="GET">
						<input type="text" name="q" value="<%=Request.QueryString("q")%>" size="10">
						<p align="right">
							<input name="Cerca" type="image" src="<%=Path_Img%>pulsante_cerca.gif" alt="Cerca" border="0">	
	</form>

per cercare con il form select come si fa?
 
Discussioni simili
Autore Titolo Forum Risposte Data
S domanda semplice per actionscript in una galleria foto Flash 2
S Domanda semplice per con SCENE e TARGET Flash 1
booklisa [PHP] Domanda semplice (apparantemente) PHP 4
S Semplice domanda con Javascript Javascript 3
S una domanda semplice da una studentesa in crisi!! PHP 1
C Semplice domanda di un neofita HTML e CSS 1
T Domanda valutazione html LinkedIn 2022 pt3 HTML e CSS 7
T Domanda valutazione html LinkedIn 2023 pt2 HTML e CSS 15
T Domanda valutazione html LinkedIn 2023 pt1 HTML e CSS 1
S Domanda stupida... C/C++ 0
F domanda sul link juice SEO e Posizionamento 2
A domanda da principiante di facebook... Discussioni Varie 1
G Salutazioni...e 1 domanda Presentati al Forum 1
Annalisa83 Domanda spinosa SEO e Posizionamento 1
L [HTML] Domanda: Utilizzo script HTML e CSS 0
G [HTML] Domanda su responsive topnav HTML e CSS 0
jonnino2004 domanda su acquisto dominio libero Domini 1
T4MAR4 [HTML] punti di domanda al posto delle lettere accentate HTML e CSS 2
booklisa [PHP] Domanda scema di sintassi PHP 2
T Domanda su Schema e Relazione Database 0
delphorm [PHP] Domanda stupida (credo) PHP 10
D domanda su EOF Visual Basic 2
G Domanda css HTML e CSS 0
G Domanda sul metodo GET PHP 1
P domanda su galleria HTML e CSS 4
L Domanda difficile: ecommerce CSV 20 000 prodotti E-Commerce 3
otto9due Piccola domanda su ++ e -- operatori di incremento/decremento PHP 0
otto9due Altra piccola domanda di approfondimento PHP 5
otto9due Piccola domanda di approfondimento PHP 3
T Domanda difficile... Javascript 21
R qualche domanda generale PHP 1
P Ciao a tutti ragazzi! avrei subito una domanda da farvi riguardo WORDPRESS, NETWORK, Presentati al Forum 1
Gabriele Visioli Domanda: rapporto fra Visite e Traffico Hosting 3
G Domanda sul sito facebook Discussioni Varie 0
F Domanda per javascript Javascript 0
A Domanda sulla modifica di CSS esistenti HTML e CSS 1
Gabriele Visioli Gestione DNS economico e domanda su affiliazioni legata ad esso Hosting 2
P Domanda... Discussioni Varie 4
filippino phpBB: spam nonostante captcha e domanda di sicurezza phpBB 0
R domanda su guadagni con sito non altervista Guadagnare col Sito 1
M Domanda riguardo i risultati della ricerca di google Joomla 14
bit77 Domanda! ho un file xml e devo estrapolare determinati testi, php è la soluzione? PHP 0
S Domanda per aprire una cartella PHP 0
P Domanda su File Database .sql di un forum Database 1
asheron Domanda importante, sulla vendita di pubblicità online: Vendere e Acquistare pubblicita' online 1
asevenx domanda su include e iframe PHP 3
A Mi presento con una domanda... XD Presentati al Forum 2
P Domanda da neofita : rubrica con diverse tipologia contatto Database 5
D Domanda copyright codice Leggi, Normative e Fisco 3
borgo italia domanda sui cookie PHP 4

Discussioni simili