<%
ricerca=sicurezza(request.Form("ricerca"))
if ricerca="" then
ricerca=request.QueryString("ricerca")
end if
if ricerca <> "" then
ricerca=Ltrim(ricerca)
ricerca=Rtrim(ricerca)
sqlup="insert into ricerca (titolo, idlingua) values ('"&ricerca&"','"&idlingua&"')"
set rsup=conn.execute(sqlup)
'______________ cerca nelle categorie dei prodotti ______________________
sql1="select idcat from categorie_prodotti where titolo like '%"&ricerca&"%' and idlingua="&idlingua&""
set rs1=conn.execute(sql1)
if not rs1.eof then
do while not rs1.eof
cat2=cat2&","&rs1("idcat")
rs1.movenext
loop
cat2=mid(cat2,2)
cat=" and idcat in ("&cat2&")"
else
cat=""
end if
rs1.close
'______________ cerca nei TAG ______________________
sql2="select idtags from tags where titolo like '%"&ricerca&"%' and idlingua="&idlingua&""
set rs2=conn.execute(sql2)
if not rs2.eof then
do while not rs2.eof
idtags=idtags&","&rs2("idtags")
rs2.movenext
loop
if idtags <> "" then
idtags=mid(idtags,2)
sql3="select idprodotti from tag_prodotti where idtags in ("&idtags&")"
set rs3=conn.execute(sql3)
if not rs3.eof then
do while not rs3.eof
idprodotti=idprodotti&","&rs3("idprodotti")
rs3.movenext
loop
idprodotti=mid(idprodotti,2)
prodotti=" and idprodotti in ("&idprodotti&")"
else
prodotti=""
end if
rs3.close
end if
rs2.close
else
prodotti=""
end if
if cat="" and prodotti="" then
sql4="select count(*) as record from prodotti where idlingua="&idlingua&" and (titolo like '%"&ricerca&"%' or corpo like '%"&ricerca&"%') order by titolo asc"
else
sql4="select count(*) as record from prodotti where idlingua="&idlingua&" "&cat&" "&prodotti&" order by titolo asc"
end if
set rs4=conn.execute(sql4)
if not rs4.eof then
record=rs4("record")
end if
rs4.close
%>
Hai cercato: <%=ricerca%>
Risultati: <%=record%>
<%
if cat="" and prodotti="" then
sql="select * from prodotti where idlingua="&idlingua&" and (titolo like '%"&ricerca&"%' or corpo like '%"&ricerca&"%') order by titolo asc"
else
sql="select * from prodotti where idlingua="&idlingua&" "&cat&" "&prodotti&" order by titolo asc"
end if
set rs=conn.execute(sql)
do while not rs.eof
n_prod=n_prod&","&rs("idprodotti")
desc=rs("corpo")
if desc <> "" then
desc=sHTMLtoTXT(desc)
desc=anteprima(desc,30)
end if
titolo=rs("titolo")
catid=rs("idcat")
idprodotti=rs("idprodotti")
filename= ConvertiTitoloInNomeScript(Titolo, IDprodotti)
set categ=conn.execute("select * from categorie_prodotti where idcat="&catid&" and idlingua="&idlingua)
if not categ.eof then
categoria=categ("titolo")
cartella=rimuoviascii(categoria)
end if
categ.close
%>
<%=categoria%>
<%=desc%>
<%rs.movenext
loop
rs.close
%>
<%
end if
%>