ok scusate nn conoscevo la funzione per incollare indentato.
offerta:
codice:
<table>
<tr>
<td align="center" valign="top" class="TITOLI">PARCO AUTO</td>
</tr>
<tr>
<td>
<%
set dbconn = server.createobject("adodb.connection")
dbconn.open(application("strconn"))
set rstcategorie = server.createobject("adodb.recordset")
dim sql
SQL = "SELECT * FROM parco_auto"
set rstCategorie = dbconn.Execute(SQL)
if not rstCategorie.EOF then
response.write "<TABLE BORDER=1 class='menu'><tr>"
For i=1 to rstCategorie.Fields.Count-4
response.write "<td>" & rstCategorie.fields(i).Name & "</td>"
Next
response.write "</tr>"
rstCategorie.MoveFirst
While not rstCategorie.EOF
response.write "<tr>"
For i=1 to rstCategorie.Fields.Count-4
if i=1 and Session("ruolo") = "admin" then
response.Write("<td>" & rstCategorie.Fields(i).value & "</td>")
else
response.write "<td>" & rstCategorie.Fields(i).value & "</td>"
end if
Next
response.write "</tr>"
rstCategorie.MoveNext
Wend
response.write "</TABLE>"
End if
Set rstCategorie=Nothing
dbconn.Close
%>
</td>
</tr>
</table>
--------------------------------------------------------------------------------
modifica_parco_auto2.asp
codice:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Documento senza titolo</title>
<script>
function vai_click(param){
document.getElementById("funzione").value = param;
document.forms[0].submit();
}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<form method="post">
<%
if request.querystring("id") <> "" then
set dbconn = server.createobject("adodb.connection")
dbconn.open(application("strconn"))
set rstprodotto = server.createobject("adodb.recordset")
dim sql
sql = "select * from parco_auto where id = " & request.querystring("id")
set rstprodotto = dbconn.execute(sql)
dim marca, modello, cilindrata, alimentazione, cavalli, anno, km, prezzo
marca = rstprodotto.Fields("marca")
modello = rstprodotto.Fields("modello")
cilindrata = rstprodotto.Fields("cilindrata")
alimentazione = rstprodotto.Fields("alimentazione")
cavalli = rstprodotto.Fields("cavalli")
anno = rstprodotto.Fields("anno")
km = rstprodotto.Fields("km")
prezzo = rstprodotto.Fields("prezzo")
rstprodotto.close()
dbconn.close()
end if
%>
<table>
<tr>
<td width="400" align="left" valign="top"><input type="text" id="marca" name="marca" value="<%=marca%>">marca</td>
</tr>
<tr>
<td width="400" align="left" valign="top"><input type="text" id="modello" name="modello" value="<%=modello%>">modello</td>
</tr>
<tr>
<td width="400" align="left" valign="top"><input type="text" id="cilindrata" name="cilindrata" value="<%=cilindrata%>">cilindrata</td>
</tr>
<tr>
<td width="400" align="left" valign="top"><input type="text" id="alimentazione" name="alimentazione" value="<%=alimentazione%>">alimentazione</td>
</tr>
<tr>
<td width="400" align="left" valign="top"><input type="text" id="cavalli" name="cavalli" value="<%=cavalli%>">cavalli</td>
</tr>
<tr>
<td width="400" align="left" valign="top"><input type="text" id="anno" name="anno" value="<%=anno%>">anno</td>
</tr>
<tr>
<td width="400" align="left" valign="top"><input type="text" id="km" name="km" value="<%=km%>">km</td>
</tr>
<tr>
<td width="400" align="left" valign="top"><input type="text" id="prezzo" name="prezzo" value="<%=prezzo%>">prezzo</td>
</tr>
<tr>
<td width="120">
<input type="button" id="inserisci" value="insert" onclick="vai_click('i');">
<input type="button" id="aggiorna" value="aggiorna" onclick="vai_click('a');">
<input type="button" id="elimina" value="elimina" onclick="vai_click('e');">
<input type="hidden" id="funzione" >
</td>
</tr>
</table>
</form>
<%
if errore = false then
Response.Write("errore=false") 'TEST
set dbconn = server.createobject("adodb.connection")
dbconn.open(application("strconn"))
set rstprodotto = server.createobject("adodb.recordset")
if Request.Form("funzione") = "i" then 'SE I FARE INSERT
Response.Write("Inserimento") 'TEST_SQL
sql = "insert into parco_auto (marca, modello, cilindrata, alimentazione, cavalli, anno, km, prezzo) values ('" & request.form("marca") & "', '" & request.form("modello") & "', '" & request.form("cilindrata") & "', '" & request.form("alimentazione") & "', '" & request.form("cavalli") & "', '" & request.form("anno") & "', '" & request.form("km") & "', '" & request.form("prezzo") & "')"
elseif Request.Form("funzione") = "e" then'SE E FARE DELETE
Response.Write("Cancellazione") 'TEST_SQL
sql = "DELETE * FROM parco_auto WHERE id = " & request.querystring("id")
elseif Request.Form("funzione") = "a" then 'SE A FARE UPDADE
Response.Write("Aggiornamento") 'TEST_SQL
sql = "UPDATE parco_auto SET marca = '" & request.form("marca") & "', modello = '" & request.form("modello")
end if 'chiusura if per selezione sql
set rstprodotto = dbconn.execute(sql)
rstprodotto.close()
dbconn.close()
end if 'chiusura if errore=false
%>
</body>
</html>