Location: PHPKode > projects > php movie db > elenchi/elenco_programmi.php
<?
	$livello=controlla_privilegi($db,$mov_id_ut,3);
	OpenTable(_RICERCA_PROGRAMMI);
		echo "<form name='form_elenco' method=\"post\" action=\"$PHP_SELF\">";
			echo "<input type='hidden' name='page' value='$page'>";
			echo "<tr>";
				echo "<td align='center'>";
					echo "<b>"._CAT."</b>";
					select_categorie($db,'categorie',1,0,'prog');
				echo "</td>";
				echo "<td align='center'>";
					echo "<b>"._NOME_PROGRAMMA." :</b><input type='text' name='nome_att'>";
				echo "</td>";
			echo "</tr>";
			echo "<tr>";
				echo "<td colspan='2' align='center'>";
					echo "<input type='submit' name='cerca' value='"._CERCA."'>";
				echo "</td>";
			echo "</tr>";
			echo "</FORM>";
	CloseTable();
				
	if ((isset($cerca))and(isset($page)))
	{
		$testo="select * from programmi";
		$mod=0;
		if (($cerca==_CERCA)and($categorie>0))
		{
			$testo.=" where id_cat=$categorie";
			$mod=1;
		}
		if (isset($regia)and($regia!=""))
		{
			if ($mod==1)
				$testo.=" and";
			else
				$testo.=" where";
				
			$testo.=" regia like '%$regia%'";
		
		}
		if (isset($nome_att)and ($nome_att!=""))
		{
			if ($mod==1)
				$testo.=" and";
			else
				$testo.=" where";
				
			$testo.=" attori like '%$nome_att%' ";
		}
		if (isset($titolo)and($titolo!=""))
		{
			if ($mod==1)
				$testo.=" and";
			else
				$testo.=" where";
				
			$testo.=" titolo like '%$titolo%' ";
		}
		$testo.=" order by id_cat,id";
		
		$res=mysql_query($testo,$db);
		//echo "<p>$testo</p>";
		$num=mysql_num_rows($res);
		OpenTable(_ELENCO_FILM);
		echo "<tr bgcolor='yellow'>";
			echo "<td align=\"center\">";
				echo "<font ><b>Nome</b></font>";
			echo "</td>\n";
			echo "<td align=\"center\">";
				echo "<font ><b>Categoria</b></font>";
			echo "</td>\n";
			echo "<td align=\"center\">";
				echo "<font ><b>Scheda</b></font>";
			echo "</td>\n";
			if ($livello==1 or $livello==10)
			{
				echo "<td BGCOLOR=\"$bgcolor4\" align=\"center\">";
					echo "<font color=\"$textcolor2\"><b>Modifica</b></font>";
				echo "</td>\n";
			
			}
		echo "</tr>";
		
		$a = 0;
        $dcolor_A = "$bgcolor2";
        $dcolor_B = "$bgcolor3";
		
		for ($i=0;$i<$num; $i++)
		{
			$nome=mysql_result($res,$i,'nome');
			$id=mysql_result($res,$i,'id');
			
			$categorie=mysql_result($res,$i,'id_cat');
			$nome_cat=converti_id_cat($categorie,$db,'prog');
			
			$dcolor = ($a == 0 ? $dcolor_A : $dcolor_B);
			
			//echo "<tr><td>$id - $titolo</td>";
			echo "<tr bgcolor=$dcolor><td>$id - $nome</td>";
			echo "<td>$nome_cat</td>";
			echo "<td><a href='$PHP_SELF?page=elenchi\scheda_prog.php&id_prog=$id'>Scheda</a></td>";
			if ($livello==1 or $livello==10)
			{
				echo "<td><a href='$PHP_SELF?page=inserimento\modifica_prog.php&id_prog=$id&invia="._MODIFICA."'>modifica</a></td>";
			}
			echo "</tr>";
			$a = ($dcolor == $dcolor_A ? 1 : 0);
		}
		
		CloseTable();
	}
	
	
?>
Return current item: php movie db