";
function Aggiungi($tbl, $id)
{
include("required.php");
$db = mysql_connect($ip, $user, $password);
mysql_select_db($dataname,$db);
$liv = Livello($tbl);
if ($liv > 1 )
{
$tabella = Tabella($liv-1);
$chiave = Chiave($liv-1);
$sql = "INSERT INTO $tabella (".$chiave.") VALUES ($id)";
//echo $sql;
$sal = mysql_query($sql, $db);
if (!$sal)
echo "
Salvataggio non riuscito!
";
}
else
echo "
Impossibile aggiungere altri elementi!
";
}
function Aggiorna($tabella, $id)
{
include("required.php");
$db = mysql_connect($ip, $user, $password);
mysql_select_db($dataname,$db);
$query = "INSERT INTO $tabella (";
for($x = 0; $x < $num_fields-1; $x++)
$query .= " ".mysql_field_name($result, $x).",";
$query .= " ".mysql_field_name($result, $num_fields-1)."";
$query .= ") VALUES ( ";
for($x = 0; $x < $num_fields-1; $x++)
$query .= " '".$valori[mysql_field_name($result, $x)]."',";
$query .= " '".$valori[mysql_field_name($result, $x)]."')";
//echo $query;
$sal = mysql_query($query, $db);
if (!$sal)
echo "
Salvataggio non riuscito!
";
}
function Livello($tabella)
{
include("required.php");
$db = mysql_connect($ip, $user, $password);
mysql_select_db($dataname,$db);
$criteri = "SELECT * FROM $tbl_livelli WHERE tabella = '$tabella'";
//echo $criteri;
$result = mysql_query($criteri, $db);
if ($myrow = mysql_fetch_array($result))
return $myrow[livello];
else
return 0;
}
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 "";
}
?>