codice HTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>News - Sezione di aggiornamento</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#999999" text="#FFFFFF">
<p><img src="../images/object1264150268.png" align="absmiddle"> <font size="+3"><strong> Amministrazione
del Sito </strong></font>
<table width="100%" border="0">
</p>
<p> </p>
<p> </p>
<tr>
<td width="20%" valign="top">
<p><a href="affittipr.php">Corsi</a></p>
<p><a href="affitti.php">News</a></p>
<p><br>
</p></td>
<td width="80%" valign="top"><font size="+1"><em><strong>Elenco
delle news</strong></em></font><br>
<br>
<?php
global $id_aff;
global $affitti;
global $img;
global $img_small;
global $descrizione;
global $zona;
global $cod_aff;
global $rif;
//Connessione
include 'conn.php';
//Leggo i dati dal DB
$dati=mysql_query("select id_aff, affitti, descrizione, zona, img_small from AFFITTI order by affitti");
//Controllo che siano caricati i dati
if (mysql_num_rows($dati)>0) {
while ($rs=mysql_fetch_array($dati, MYSQL_BOTH)) {
echo "<img src='../admin/images/".$rs["img_small"]."' border='0' align='absmiddle'> -
".$rs["affitti"]."<br><a href=classi.php?id_aff=".$rs["id_aff"].">
</a> <br>
<a href='aff_modifica.php?id_aff=".$rs["id_aff"]."'>Maodifica questa news</A><br><br>
<a href='aff_elimina.php?id_aff=".$rs["id_aff"]."'>Elimina questa news</a><br><br>"
;
}
}
echo "<br><br><a href='aff_modifica.php?id_aff=0'>Inserisci una news</A><br>"
?>
</body>
</html>
Aff_modifica.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Amministrazione</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#999999" text="#FFFFFF">
<img src="../images/object1264150268.png" align="absmiddle"> <font size="+3"><strong> Amministrazione
del Sito </strong></font>
<table width="100%" border="0">
<tr>
<td width="20%" valign="top">
<p><a href="affittipr.php">Corsi</a></p>
<p><a href="affitti.php">News</a></p>
</td>
<?php
//Connessione
include 'conn.php';
$conn=mysql_connect($host,$user,$pwd);
mysql_select_db($db,$conn);
//scrivo il nome della affitti
if ($id_aff!=0) {
$daticat=mysql_query("select affitti from AFFITTI where id_aff=$id_aff");
while ($rscat=mysql_fetch_array($daticat, MYSQL_BOTH)) {
echo "<b>".$rscat["affitti"]."</b><br><br>";
}
$target="aff_chg.php";
$dati=mysql_query("select affitti, img, descrizione, zona,rif, img_small from AFFITTI where id_aff=$id_aff");
//Controllo che siano caricati i dati
if (mysql_num_rows($dati)>0) {
while ($rs=mysql_fetch_array($dati, MYSQL_BOTH)) {
//leggo i dati e li memorizzo
$affitti=$rs["affitti"];
$descrizione=$rs["descrizione"];
$zona=$rs["zona"];
$img=$rs["img"];
$img_small=$rs["img_small"];
$rif=$rs["rif"];
}
}
else echo "Errore - Non esiste questa news<br><br>";
}
else {
$target="aff_add.php";
echo "<b>Inserimento di una nuova Vendita</b>";
}
echo "<form action='$target' method='post' enctype='multipart/form-data'>";
?>
<table width="100%" cellspacing="1" cellpadding="3" >
<tr>
<td width="13%" valign="top"> </td>
<td width="7%" valign="top"><strong>Titolo:</strong></td>
<td width="80%">
<?php
echo "<input type='text' name='affitti' value='$affitti'>";
?>
</td>
</tr>
<tr>
<td valign="top"> </td>
<td valign="top"><strong>File:</strong></td>
<td>
<?php
if ($img_small!="")
echo "<img src='../admin/images/$img_small'>";
?>
<br> <input type="file" name="img_small"> <br> <input name="el_img_small" type="checkbox" value="1">
Sostituisci l'immagine<br> </td>
</tr>
<tr>
<td valign="top"> </td>
<td valign="top">Corpo:</td>
<td><textarea name="descrizione" id="descrizione" cols="45" rows="5">
</textarea></td>
</tr>
<tr>
<td colspan="3" align="left" valign="top"> <div align="center"><br>
<input type="submit" name="Submit" value=" Invia "></form>
</div></td>
</tr>
<tr>
<td colspan="3" valign="top"> <p> </p></td>
</tr>
</table>
<?php
echo "</form>";
?>
</body>
</html>