All pastes #137550 Raw Edit

Mine

public text v1 · immutable
#137550 ·published 2006-08-18 13:38 UTC
rendered paste body
<?PHP

include 'include/connect.inc.php';
include 'include/func.inc.php';
$c=connect();
//on va chercher les catégories principales
$sql="select * from CATEGORIES where id_parent=1 order by name";
//execution requete
$main=odbc_do($c,$sql);

while(odbc_fetch_row($main))
	{
	$name=odbc_result($main,"name");
	$id_cat=odbc_result($main,"id_cat");	
	$id_parent=odbc_result($main,"id_parent");	
	echo $name.'<br>';
	recursive($id_cat);	
	}
	
//_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
//_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/

Ici il faut que tu ais ton tableau

//_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
//_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/


function recursive($id_cat)
{
$c=connect();
			$sub=odbc_do($c,"select * from categories where id_parent=$id_cat") or die('error sql');
			$count=odbc_num_rows($sub);
			if($count>0)
			{
			while(odbc_fetch_row($sub))
					{
					$name=odbc_result($sub,"name");
					$id_cat=odbc_result($sub,"id_cat");
					$id_parent=odbc_result($sub,"id_parent");
					$out='>'.$name.'<br>';
					echo $out;	

//// IF (in_array($id_cat, $tableau_parents)){
////////////recursive.....
///////////////////}
					//recursive($id_cat);					
					}
					
			}
			
				
				
}

?>