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
		
			
				
	
	
		
			138 lines
		
	
	
		
			3.1 KiB
		
	
	
	
		
			PHP
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			138 lines
		
	
	
		
			3.1 KiB
		
	
	
	
		
			PHP
		
	
	
		
			Executable File
		
	
	
	
	
| <html>
 | |
| <head>
 | |
| 	<title></title>
 | |
| 	<LINK rel="stylesheet" type="text/css" href="stile.css">
 | |
| </head>
 | |
| 
 | |
| <body>
 | |
| <?php
 | |
| include("required.php");
 | |
| $db = mysql_connect($ip, $user, $password);
 | |
| mysql_select_db($dataname,$db);
 | |
| 	
 | |
| if (isset($tbl) && isset($id))
 | |
| 	Elimina($tbl,$id);
 | |
| else
 | |
| 	echo "<br><br><p class=error>Impossibile eliminare!</p><br><br>";
 | |
| 
 | |
| 
 | |
| 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."<br>";
 | |
| 	$canc = mysql_query($sql, $db);
 | |
| 	if (!$canc)
 | |
| 		echo "<br><br><p class=error>Eliminazione non riuscita!</p><br><br>";
 | |
| 	
 | |
| 	$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."<br>";
 | |
| 			//$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."<br>";
 | |
| 				//}
 | |
| 				
 | |
| 				//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."<br>";
 | |
| 					$resultx = mysql_query($criterix, $db);
 | |
| 					if ($myrowx = mysql_fetch_array($resultx))
 | |
| 					{
 | |
| 						do
 | |
| 						{
 | |
| 							echo $myrowx[id]."<br>";
 | |
| 							$nuovi[] = $myrowx[id];
 | |
| 							//$query = "DELETE FROM $tbl WHERE id = $temp";
 | |
| 							$query = "DELETE FROM $tbl WHERE id = $myrowx[id]";
 | |
| 							//echo $query."<br>";
 | |
| 							$el = mysql_query($query, $db);
 | |
| 							if (!$el)
 | |
| 								echo "<br><br><p class=error>Eliminazione non completata!</p><br><br>";
 | |
| 						}while ($myrowx = mysql_fetch_array($resultx));
 | |
| 					}
 | |
| 				}
 | |
| 			}
 | |
| 			$livello--;
 | |
| 		}
 | |
| 	}
 | |
| 	else
 | |
| 		echo "<br><br><p class=error>Tabella '$tabella' non trovata!</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 "";
 | |
| }
 | |
| 
 | |
| function Vuota($array)
 | |
| {
 | |
| 	$array = array();
 | |
| 	
 | |
| 	while (count($array))
 | |
| 		array_shift($array);
 | |
| 
 | |
| 
 | |
| }
 | |
| 
 | |
| ?>
 | |
| 
 | |
| </body>
 | |
| </html>
 | |
| 
 |