Salve, ho un problema nel visualizzare un elenco suddiviso per regioni, ho un database access con una tabella "negozi" in cui ci sono i seguenti campi:
id, regione, citta, via, cap, provincia. Ho usato il ciclo "
<%
rst.movefirst
do while not rst.EOF
%>",
questo mi permette di visualizzare le regione e le città; avendo più città sotto la stessa regione, queste vengono ripetute ad ogni città, io vorrei invece che la regione si ripetesse solo una volta e poi con le elenco delle città corrispondenti, e via via con le altre regioni. Come potri fare?? ho provato con distinct ma mi da dei problemi, questo è il codice:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
'creo e apro connessione al database
dim cn
set cn =server.CreateObject("adodb.connection")
cn.open"driver={microsoft access driver (*.mdb)};dbq="&server.MapPath("mdb-database/fergi.mdb")
'creo un recordset che usa la connessione e lo apro
dim rst
set rst=server.CreateObject("adodb.recordset")
rst.activeConnection=cn
rst.source="SELECT DISTINCT regione FROM negozi ORDER BY regione"
rst.cursortype=2
rst.cursorlocation=2
rst.locktype=2
rst.open ()
'creo una variabile boleana che diventa vera se il recordset non contiene dati
dim noCategoria
noCategoria=false
'se il recordset è finito il valore di noCategoria è vero
if rst.EOF then
noCategoria=true
end if
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<style type="text/css">
<!--
body {
background-image: url();
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
-->
</style>
<link href="stile.css" rel="stylesheet" type="text/css">
<script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
<link href="admin.css" rel="stylesheet" type="text/css">
</head>
<body>
<div align="center">
<table width="740" height="30" border="0" cellpadding="5" cellspacing="0">
<tr>
<th width="370" scope="row"><div align="left" class="link">Punti vendita | Lista CV | News eventi | Stampa </div></th>
<th width="370" scope="row"><div align="right" class="link">log out </div></th>
</tr>
</table>
<table width="740" height="80" border="0" cellpadding="5" cellspacing="0" bgcolor="#DE1F82">
<tr>
<th scope="row"><div align="right" class="titolo">AREA RISERVATA </div></th>
</tr>
</table>
<table width="740" height="30" border="0" cellpadding="5" cellspacing="0">
<tr>
<th width="740" class="link" scope="row"><div align="center">Inserisci regione|Ricerca regione (modifica/cancella)|Inserisci punto vendita|Ricerca punto vendita (modifica/cancella)</div></th>
</tr>
</table>
<table width="740" height="15" border="0" cellpadding="0" cellspacing="0">
<tr>
<th width="740" scope="row"><hr width="740" size="1" noshade></th>
</tr>
</table>
<table width="740" height="400" border="0" cellpadding="5" cellspacing="0">
<tr>
<th valign="top" scope="row"><div align="left"><span class="titolo2">Elenco punti vendita </span>
<table width="200" height="10" border="0" cellpadding="5" cellspacing="0">
<tr>
<td class="categorie"></td>
</tr>
</table>
<table width="200" border="0" cellpadding="5" cellspacing="0">
<tr>
<% if noCategoria then%>
<td class="testo">Non ci sono categorie disponibili </td>
</tr>
</table>
<% else%>
<%
rst.movefirst
do while not rst.EOF
%>
<table width="390" border="0" cellpadding="0" cellspacing="0">
<tr>
<th class="testo" scope="row"><div align="left"><%=rst("regione")%></div></th>
<th valign="bottom" scope="row"></th>
</tr>
<tr>
<th width="128" class="testo" scope="row"><%=rst("citta")%>
<div align="left">
</div></th>
<th width="262" valign="bottom" scope="row"><form name="form1" method="post" action="aggiornamentoRegione.asp">
<label>
<div align="left">
<input name="codiceNotizia" type="hidden" value=<%'=rst("id")%>>
<input name="Submit" type="submit" class="testo" value="Modifica">
</div>
</label>
</form></th>
</tr>
</table>
<% 'vai al record successivo
rst.movenext
'ripeto il ciclo
loop %>
<%end if%>
</div></th>
</tr>
</table>
<table width="740" height="40" border="0" cellpadding="5" cellspacing="0" bgcolor="#DE1F82">
<tr>
<th scope="row"><div align="right" class="titolo">
<div align="left">Copyrright FERGI.it 2006 </div>
</div></th>
</tr>
</table>
</div>
</body>
</html>
<% rst.close ()
set rst= nothing
cn.close ()
set cn= nothing
%>
qualcuno mi potrebbe aiutare?

Rispondi quotando