Ciao , mi chiamo Andrea ho un sito di annunci gratuiti in Asp.
Mi è venuta la spiga di mettere le categorie in ordine alfabetico,
mi chiedevo se si può fare ???? e se mi potete aiutare .
Il sito è questo
http://www.mercatinoplus.net
Ciao e grazie
Ciao , mi chiamo Andrea ho un sito di annunci gratuiti in Asp.
Mi è venuta la spiga di mettere le categorie in ordine alfabetico,
mi chiedevo se si può fare ???? e se mi potete aiutare .
Il sito è questo
http://www.mercatinoplus.net
Ciao e grazie
ci stai dicendo troppo poco. dacci almeno la struttura delle tabelle, e indica le query che ui attualmente
Buon giorno ti invio ( Categorie )
ciao e grazie
-------------------------------------------------------------------------
<%
Dim id_regione, id_provincia, id_comune, MyConn, rs2, sql2
cat = Request.QueryString("CatID")
Subcat = Request.QueryString("Subcat")
categoria = Request.QueryString("categoria")
id_regione = request.querystring("id_regione")
id_provincia = request.querystring("id_provincia")
id_comune = request.querystring("id_comune")
if id_regione ="" then id_regione=request.form("id_regione")
if id_provincia="" then id_provincia=request.form("id_provincia")
if id_comune="" then id_comune=request.form("id_comune")
'if id_regione="" then id_regione=0
'if id_provincia ="" then id_provincia =0
'if id_comune ="" then id_comune =0
%>
<html>
<head>
<title>Categorie</title>
<style>
A:link, A:visited { text-decoration: none }
A:hover { text-decoration: underline }
</style>
</head>
<body topmargin="0">
<div align="center">
<center>
<table border="0" width="730" cellpadding="0" cellspacing="1" height="1">
<caption></caption>
<tr>
<td height="1" valign="top" bgcolor="#ABCDEF">
<p align="center">[img]immagini/Ricerca.gif[/img]</td>
<td width="1%" rowspan="6" height="1" valign="top">[img]immagini/null.gif[/img]</td>
<td width="95%" height="1" valign="top" bgcolor="#ABCDEF"></td>
</tr>
<tr>
<td width="18%" height="1" valign="top" bgcolor="#EDEDED" rowspan="4">
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td width="100%" valign="top">
<div align="center">
<center>
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td valign="top" bgcolor="#EDEDED">
<form method="get" action="search.asp">
<div align="center">
<table border="0" cellpadding="0" cellspacing="0" >
<tr><td>
<p align="center"><font size="1" face="Arial">
<input name="search" size="13" >
</font>
</td>
</tr>
<tr>
<td>
<p align="center"><font size="1" face="Arial">
</font>
<font size="2" face="Arial">
<select name="xxx" size="1">
<option value="1">Parola esatta</option>
<option value="2">Tutte le parole</option>
</select></font>
</td>
</tr>
<tr>
<td>
<p align="center"><font size="1" face="Arial">
<input type="submit" value="Ricerca" >
</font>
</td>
</tr>
<tr>
<td>
<p align="center"><font face="Arial" size="1">Risultato per
pagina
<input type="radio" value="10" checked name="num">
10 <input type="radio" name="num" value="20">20
<input type="radio" name="num" value="30">
30</font>
</td>
</tr>
</table>
</div>
</form>
</td>
</tr>
<tr>
<td bgcolor="#EDEDED" valign="top">
<p align="center">
</p>
</td>
</tr>
<tr>
<td bgcolor="#EDEDED" valign="top">
</td>
</tr>
</table>
</center>
</div>
</td>
</tr>
</table>
</td>
<td valign="top" height="196">
<div align="center">
<table border="0" width="98%" cellspacing="0" cellpadding="0">
<tr>
<td width="100%" valign="top">
<p align="center"><script type="text/javascript"><!--
google_ad_client = "ca-pub-4726577151331453";
/* Business */
google_ad_slot = "5622819664";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<p align="center"><font face="Glowing Steel" color="#6699FF" size="4">
Categoria : <%=categoria%></font></td>
</tr>
<tr>
<td valign="top">
<hr size="1" color="#98A0B8">
<%
sql = "SELECT * From SotCategorie where CategoriaID='" & cat & "' order by NomeCategoria"
set rs = Conn.Execute (sql)
IF rs.EOF then
Response.Write "<center><font color='#838383'>Categoria non ancora definita
</font>"
Else
End IF
%>
<div align="center"><table border="0" width=525>
<%
if request.querystring("op")="" then
%>
<!--
Annunci</p>-->
<%
else
Set MyConn=Server.CreateObject("ADODB.Connection")
MyConn.Open "Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.Mappath("/mdb-database/mercatino.mdb")
if id_regione<>"" then
%><p style="text-align: center; font-size: 14pt;">Annunci in zona:
<%
SQL2 = "Select * From regioni where id_regione="&id_regione&""
Set RS2 = MyConn.Execute(SQL2)
While Not RS2.EOF
%>
<%=rs2("regione")%>
<%
RS2.MoveNext
Wend
RS2.Close
Set RS2 = Nothing
%>
<%
end if
if id_provincia<>"" then
%>
<%
SQL2 = "Select * From province where id_provincia="&id_provincia&""
Set RS2 = MyConn.Execute(SQL2)
While Not RS2.EOF
%>
> <%=rs2("provincia")%>
<%
RS2.MoveNext
Wend
RS2.Close
Set RS2 = Nothing
%>
<%
end if
if id_comune<>"" then
%>
<%
SQL2 = "Select * From comuni where id_comune="&id_comune&""
Set RS2 = MyConn.Execute(SQL2)
While Not RS2.EOF
%>
> <%=rs2("comune")%>
<%
RS2.MoveNext
Wend
RS2.Close
Set RS2 = Nothing
%>
<%
end if
MyConn.Close
Set MyConn = Nothing
%></p><%
end if
%>
<%
Do while NOT rs.EOF
ColNum = 1
Do while ColNum < 3
%>
<TD ALIGN=LEFT VALIGN=top WIDTH="269">[img]<%=rs([/img]"> <font face="Arial" size="2"> &Subcat=<%=rs("CategoriaID")%>&categoria=<%=server .urlencode(categoria)%>&cat=<%=server.urlencode(rs ("NomeCategoria"))%><%if request.querystring("op")="filtra" then%>&op=filtra&id_regione=<%=id_regione% >&id_provincia=<%=id_provincia%>&id_comune =<%=id_comune%><%end if%>"><%=rs("NomeCategoria")%>
<font face="Arial" size="1">
<%
IDCategoria = rs("IDSottocategoria")
if request.querystring("op")="" then
sqlcount = "SELECT count(Titolo) FROM annunci where IDCategoria='" & IDCategoria & "' and show=yes"
else
if id_regione<>"" then
sqlcount = "SELECT count(Titolo) FROM annunci where IDCategoria='" & IDCategoria & "' and id_regione="&id_regione&" and show=yes"
end if
if id_provincia<>"" then
sqlcount = "SELECT count(Titolo) FROM annunci where IDCategoria='" & IDCategoria & "' and id_provincia="&id_provincia&" and show=yes"
end if
if id_comune<>"" then
sqlcount = "SELECT count(Titolo) FROM annunci where IDCategoria='" & IDCategoria & "' and id_comune="&id_comune&" and show=yes"
end if
end if
Set RScounts = Conn.Execute(sqlcount)
rcounts = RScounts(0)
Response.Write ("( " & rcounts & " )")
Response.Write "
"
Response.Write "<center><font color='#838383'>"& rs("DescrizioneSotCat")& "
</font>"
%>
</font></font></TD>
<%
if NOT rs.EOF then
rs.MoveNext
end if
ColNum = ColNum + 1
if NOT rs.EOF then
%>
<TD ALIGN=LEFT VALIGN=top WIDTH="256">[img]<%=rs([/img]"><font size="2" face="Arial"> &Subcat=<%=rs("CategoriaID")%>&categoria=<%=server .urlencode(categoria)%>&cat=<%=server.urlencode(rs ("NomeCategoria"))%><%if request.querystring("op")="filtra" then%>&op=filtra&id_regione=<%=id_regione% >&id_provincia=<%=id_provincia%>&id_comune =<%=id_comune%><%end if%>"><%=rs("NomeCategoria")%><font face="Arial" size="1">
<%
IDCategoria= rs("IDSottocategoria")
if request.querystring("op")="" then
sqlcount = "SELECT count(Titolo) FROM annunci where IDCategoria='" & IDCategoria & "' and show=yes"
else
if id_regione>0 then
sqlcount = "SELECT count(Titolo) FROM annunci where IDCategoria='" & IDCategoria & "' and id_regione="&id_regione&" and show=yes"
end if
if id_provincia>0 then
sqlcount = "SELECT count(Titolo) FROM annunci where IDCategoria='" & IDCategoria & "' and id_provincia="&id_provincia&" and show=yes"
end if
if id_comune>0 then
sqlcount = "SELECT count(Titolo) FROM annunci where IDCategoria='" & IDCategoria & "' and id_comune="&id_comune&" and show=yes"
end if
end if
Set RScounts = Conn.Execute(sqlcount)
rcounts = RScounts(0)
Response.Write ("( " & rcounts & " )")
Response.Write "
"
Response.Write "<center><font color='#838383'>"& rs("DescrizioneSotCat")& "
</font>"
RScounts.close
set RScounts = nothing
%>
</font></font></TD>
<%
END IF
ColNum = ColNum + 1
Loop
%>
<tr>
<%
IF NOT rs.EOF then
rs.MoveNext
End IF
Loop
%>
</TABLE>
</div>
<p align="left">
</td>
</tr>
</table>
</div>
<p align="center">
</td>
</tr>
<tr>
<td width="95%" height="21" valign="top">
</td>
</tr>
<tr>
<td width="95%" height="1" valign="top">
</td>
</tr>
<tr>
<td width="95%" height="1" valign="top">
</td>
</tr>
<tr>
<td width="3%" height="23" valign="top" bgcolor="#ABCDEF">
<td width="95%" height="23" valign="top" bgcolor="#ABCDEF">
</td>
</tr>
</table>
</center>
</div>
<p align="center"></p>
</body>
</html>
<%
Rs.close
set Rs = nothing
Conn.Close
set Conn = nothing
%>
onestamente, non sto a leggermi TUTTO il codice. comunque, l'ordinamento lo ottieni tramite la clausola ORDER BY, così
SELECT elenco_colonne FROM tabella WHERE condizione ORDER BY colonna
![]()
Ciao.
-----------------------------------------------
sql = "SELECT * From SotCategorie where CategoriaID='" & cat & "' order by NomeCategoria"
-------------------------------
quindi il codice sarebbe da aggiungere dalla A alla Z
mi puoi aiutare
grazie
che vuol dire "mi puoi aiutare"? hai già scritto il codice...
Ciao , io sono solo un appassionato , tu mi hai scritto (order by)non sapevo cosa voleva dire e ho controllato il codice nella pagina Categorie, dove l'ho riportato per vedere se andava bene.
<%
sql = "SELECT * From SotCategorie where CategoriaID='" & cat & "' order by NomeCategoria"
set rs = Conn.Execute (sql)
IF rs.EOF then
Response.Write "<center><font color='#838383'>Categoria non ancora definita
</font>"
Else
End IF
%>
ancora grazie
continuo a non capire. è tutto a posto adesso?
Adesso stò capendo che non riuscivi a capire.
La pagina di mio interesse è questa qui http://www.mercatinoplus.net
le categorie non sono in ordine alfabetico.E' questo che mi interessa.
Se clicchi sopra AUTOVEICOLI (per favore )le sotto categorie sono in ordine alfabetico .e se non sbaglio il codice che ti ho fatto vedere riguarda questo , che va bene.
A me interessa l'ordine alfabetico della home page.
e i codici potrebbero essere questi 2°
1° <%SQL="SELECT * FROM vhs " & SQLb & " ORDER BY Title"
2° SQL="SELECT * FROM vhs " & SQLb & " ORDER BY Title DESC"
Però la sintassi va bene così, e dove li devo mettere
Ciao e grazie ancora