campo-sirio/corsi/admin/modifica.php
alex cf0c1133fd Patch level :
Files correlati     :
Ricompilazione Demo : [ ]
Commento            :
Versione FAD del 11/10/2001


git-svn-id: svn://10.65.10.50/trunk@9917 c028cbd2-c16b-5b4b-a496-9718f37d4682
2001-10-11 12:55:16 +00:00

149 lines
4.1 KiB
PHP
Executable File

<html>
<head>
<title></title>
<LINK rel="stylesheet" type="text/css" href="stile.css">
</head>
<script language="JavaScript">
function apri()
{
document.form1.submit();
return false;
}
</script>
<body>
<?php
include("required.php");
$db = mysql_connect($ip, $user, $password);
mysql_select_db($dataname,$db);
if (isset($aggiorna))
Aggiorna($tbl, $id, $valori);
elseif (isset($tbl) && isset($id))
Modifica($tbl,$id);
else
echo "<br><br><p class=error>Impossibile eliminare!</p><br><br>";
echo "<form name=form1 action=$PHP_SELF method=get>";
echo "<table border=0 align=center>";
function Modifica($tabella, $id)
{
include("required.php");
$db = mysql_connect($ip, $user, $password);
mysql_select_db($dataname,$db);
echo "<p class=titolo>Modifica $tabella<br></p>";
$criteri = "SELECT * FROM $tabella WHERE id = $id ";
//echo $criteri;
$result = mysql_query($criteri, $db);
$myrow = mysql_fetch_array($result);
$num_fields = mysql_num_fields($result);
echo "<form name=form1 action=modifica.php method=post><table border=0 align=center>";
//$valori = array();
for($x = 0; $x < $num_fields; $x++)
{
//$tipo = "<td>".mysql_field_type($result, $x)."</td>"; // Visualizza il tipo del campo
$t = ereg_replace("'", "", $myrow[mysql_field_name($result, $x)]); // Rimozione delle stringhe del singolo apice
$dati = $t;
if ($riga == true)
{
echo "<tr class=chiaro><td>".mysql_field_name($result, $x)."</td>";
$riga = false;
}
else
{
echo "<tr class=scuro><td>".mysql_field_name($result, $x)."</td>";
$riga = true;
}
if (mysql_field_type($result, $x) == "blob")
//if (mysql_field_type($result, $x) == "blob" || mysql_field_len($result, $x) > 30 )
echo "$tipo<td><textarea cols=35 rows=3 name='valori[".mysql_field_name($result, $x)."]' wrap=hard>$dati</textarea></td></tr>";
else
{
if (strstr(mysql_field_name($result, $x), "id"))
//echo "$tipo</td><td><input type=Text size=50 name='valori[".mysql_field_name($result, $x)."]' value='$dati' ></td></tr>";
echo "$tipo</td><td><input type=hidden name='valori[".mysql_field_name($result, $x)."]' value='$dati'>$dati</td></tr>";
else
echo "$tipo</td><td><input type=text size=50 name='valori[".mysql_field_name($result, $x)."]' value='$dati'></td></tr>";
}
}
echo "<tr><td><br></td></tr>";
echo "<tr><td align=center colspan=2><input type=hidden name=tbl value=$tabella><input type=hidden name=id value=$id>";
echo "<input type=submit name=aggiorna value=Aggiorna></td></tr>";
echo "</table></form>";
}
function Aggiorna($tbl, $id, $valori)
{
include("required.php");
$db = mysql_connect($ip, $user, $password);
mysql_select_db($dataname,$db);
$criteri = "SELECT * FROM $tbl ";
//echo $criteri;
$result = mysql_query($criteri, $db);
$myrow = mysql_fetch_array($result);
$num_fields = mysql_num_fields($result);
$query = "UPDATE $tbl SET ";
for($x = 0; $x < $num_fields-1; $x++)
$query .= " ".mysql_field_name($result, $x)." = '".$valori[mysql_field_name($result, $x)]."',";
$query .= " ".mysql_field_name($result, $num_fields-1)." = '".$valori[mysql_field_name($result, $num_fields-1)]."'";
$query .= " WHERE id = $id ";
//echo $query;
$agg = mysql_query($query, $db);
if (!$agg)
echo "<br><br><p class=error>Aggiornamento non effettuato!</p><br><br>";
}
function Tabella($livello)
{
include("required.php");
$db = mysql_connect($ip, $user, $password);
mysql_select_db($dataname,$db);
$criteri = "SELECT * FROM $tbl_livelli WHERE livello = $livello";
//echo $criteri;
$result = mysql_query($criteri, $db);
if ($myrow = mysql_fetch_array($result))
return $myrow[tabella];
else
return "";
}
function Chiave($livello)
{
include("required.php");
$db = mysql_connect($ip, $user, $password);
mysql_select_db($dataname,$db);
$criteri = "SELECT * FROM $tbl_livelli WHERE livello = $livello";
//echo $criteri;
$result = mysql_query($criteri, $db);
if ($myrow = mysql_fetch_array($result))
return $myrow[chiave];
else
return "";
}
//echo "<tr><td><br></td></tr><tr><td align=center><input type=submit name=aggiorna value=Aggiorna class=bottoni></td></tr>";
echo "</table></form>";
?>
</body>
</html>