Impossibile eliminare!



"; function Elimina($tabella, $id) { include("required.php"); $db = mysql_connect($ip, $user, $password); mysql_select_db($dataname,$db); $vecchi = array(); $nuovi = array(); $sql = "DELETE FROM $tabella WHERE id = $id"; //echo $query."
"; $canc = mysql_query($sql, $db); if (!$canc) echo "

Eliminazione non riuscita!



"; $vecchi[] = $id; $criteri = "SELECT * FROM $tbl_livelli WHERE tabella = '$tabella'"; //echo $criteri; $result = mysql_query($criteri, $db); if ($myrow = mysql_fetch_array($result)) { $livello = $myrow[livello]-1; //for($x = ($myrow[livello]-1); $x > 0; $x--) while ($livello > 0) { //echo "Livello:".$livello."
"; //$tbl = Tabella($x); $tbl = Tabella($livello); if ($tbl != "") { Vuota($Vecchi); //for($j = 0; $j < $nuovi[count($nuovi-1)]; $j++) foreach($nuovi as $temp) $vecchi[] = $temp; Vuota($nuovi); //foreach($vecchi as $temp) //{ // echo "Vecchi:".$temp."
"; //} //for($j = 0; $j < $vecchi[count($vecchi-1)]; $j++) foreach($vecchi as $temp) { //$criterix = "SELECT * FROM $tbl WHERE id = $vecchi[$j]"; //$criterix = "SELECT * FROM $tbl WHERE id = $temp"; $criterix = "SELECT * FROM $tbl WHERE ".Chiave($livello)." = $temp"; //echo $criterix."
"; $resultx = mysql_query($criterix, $db); if ($myrowx = mysql_fetch_array($resultx)) { do { echo $myrowx[id]."
"; $nuovi[] = $myrowx[id]; //$query = "DELETE FROM $tbl WHERE id = $temp"; $query = "DELETE FROM $tbl WHERE id = $myrowx[id]"; //echo $query."
"; $el = mysql_query($query, $db); if (!$el) echo "

Eliminazione non completata!



"; }while ($myrowx = mysql_fetch_array($resultx)); } } } $livello--; } } else echo "

Tabella '$tabella' non trovata!



"; } 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 ""; } function Vuota($array) { $array = array(); while (count($array)) array_shift($array); } ?>