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
		
			
				
	
	
		
			129 lines
		
	
	
		
			2.7 KiB
		
	
	
	
		
			PHP
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			129 lines
		
	
	
		
			2.7 KiB
		
	
	
	
		
			PHP
		
	
	
		
			Executable File
		
	
	
	
	
| <html>
 | |
| <head>
 | |
| 	<title>Test</title>
 | |
| 	<LINK rel="stylesheet" type="text/css" href="stile.css">
 | |
| 	<META HTTP-EQUIV="Expires" CONTENT="3"> 
 | |
| </head>
 | |
| 
 | |
| <body>
 | |
| 
 | |
| <?php
 | |
| 
 | |
| include("required.php");
 | |
| include("funzioni.php");
 | |
| 
 | |
| $db = mysql_connect($ip, $user, $password);
 | |
| mysql_select_db($dataname,$db);
 | |
| 
 | |
| 
 | |
| 
 | |
| if (isset($aggiorna))
 | |
| 	Aggiorna($tbl, $id, $valori);
 | |
| elseif (isset($tbl) && isset($id))
 | |
| {
 | |
| 	
 | |
| }	
 | |
| 	
 | |
| 	
 | |
| echo "<form name=form1 action=$PHP_SELF method=get>";
 | |
| echo "<table border=0 align=center>";
 | |
| 
 | |
| 
 | |
| 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 "<br><br><p class=error>Salvataggio non riuscito!</p><br><br>";
 | |
| 	}
 | |
| 	else
 | |
| 		echo "<br><br><p class=error>Impossibile aggiungere altri elementi!</p><br><br>";
 | |
| }
 | |
| 
 | |
| 
 | |
| 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 "<br><br><p class=error>Salvataggio non riuscito!</p><br><br>";
 | |
| }
 | |
| 
 | |
| 
 | |
| 
 | |
| 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 "";
 | |
| }
 | |
| 
 | |
| 
 | |
| 
 | |
| ?>
 | |
| 
 | |
| </body>
 | |
| </html>
 |