je veux creer une arborecence
-----------------------------------------
+nom1
-nom2
+nom21
-nom22
+nom221
+nom222
+nom33
+nom3
-----------------------------------------------------
le probleme qui se pose c'est que je doi faire une fonction recursive pour remplir le tableau a partir de la BD
dc c pour cela qu je doit creer une variable session $subor=array();
$_SESSION['subor'] = array(); mais je sai pas comment parametrer ma fonction recursive
-------------------------------------------------
voila le code
-------------------------
</SCRIPT>
<?
$db = new DataBase;
$db->DbRecord($rec='oracle');
$emp_id_mgr=$_SESSION["matricule"];
$emp_id_mgr='048369';
$subor=array();
$sql1="select NAME from arhi_base_headcount_w_tp a where EMPLOYEE_ID='$emp_id_mgr'";
$Result=$db->DbSelect($sql1, $Column='1');
$nom_m=$Result[0][0];
$sql="select NAME,EMPLOYEE_ID from arhi_base_headcount_w_tp a where DIRECT_REPORT_ID='$emp_id_mgr'";
//echo $sql;
$Result2=$db->DbSelect($sql, $Column='2');
if( count($Result2) > 0)
if ($_GET["act"] == "sub")
{
$empl_id=$_GET["id_emp"];
$nom_sub=$_GET["nom_sub"]."|".$empl_id;
$sqls="select NAME,EMPLOYEE_ID from arhi_base_headcount_w_tp a where DIRECT_REPORT_ID='$empl_id'";
$Result=$db->DbSelect($sqls, $Column='2');
//function Recursive ()
//{
foreach($Result2 as $Field)
{
$vnom=$Field[0]."|".$Field[1];
$subor[$vnom].='';
}
if( count($Result) > 0)
{
$flag=0;
$chaine="array(";
foreach($Result as $Fields)
{
if ($flag==0) $chaine.= "'".$Fields[0]."|".$Fields[1]."'";
else $chaine.= ",'".$Fields[0]."|".$Fields[1]."'";
$flag=1;
}
$chaine.=")";
$chaine = "\$subor[\$nom_sub]=".$chaine.";";
eval($chaine);
echo "<br>";
//Recursive($subor);
//print_r($subor[$empl_id]);
}
}
else
{
foreach($Result2 as $Field)
{
$vnom=$Field[0]."|".$Field[1];
$subor[$vnom].='';
}
}
//}
//Recursive($subor);
print_r($subor);
//foreach($Result2 as $Field)
/*select NAME from arhi_base_headcount_w_tp a where DIRECT_REPORT_ID=''
$Result=$db->DbSelect($Sql, $Column='1');
if( count($Result) > 0)
foreach($Result as $Field)
{
if ($m[1]!=0)
*/
?>
<form name='F1' METHOD="POST" action="">
<table background="<?=$imagesPath?>header/fond_bando2.gif" width="632" border="0" align="center" cellpadding="0" cellspacing="0">
<tr width="632">
<td valign="middle" class="textegrasblanc" width="100%"><img src="<?=$imagesPath?>header/spacer.gif" border="0" width="55" height="25" align="absmiddle"><font class="text">Filtre de recherche</font></td>
</tr>
</table>
<table width="500" border="0" align="center" cellpadding="0" cellspacing="0" background="<?=$imagesPath?>header/fond_gris_m.gif">
<tr><td background="<?=$imagesPath?>header/fond_gris_h.gif"><img src="<?=$imagesPath?>header/spacer.gif" width="500" height="9"></td></tr>
<tr>
<td align='center' width='100%'><table width='90%' border="0" align="center">
<tr>
<td width="5" > </td>
<td width="10" > </td>
<td <font class="text"><b>Manager : </b></font><td ><input type="text" name="nom_manager" value="<? echo $nom_m; ?>" disabled >
<td width="6"></td>
</tr>
<tr>
<td width="5" > </td>
<td colspan="2" <font class="text"><b>Noms Collaborateurs</b></font></td>
</tr>
<?
foreach($subor as $key => $value)
{
$tnomm=explode("|",$key);
if(is_array($value))
{
?>
<tr>
<td ><a href="#" onClick="subord('<? echo $emp_id_mgr ;?>','<? echo $tnomm[1] ;?>','<? echo $tnomm[0] ;?>')" > <img src="moinsOrange" border="0"> </a></td>
<td><a href="#" onClick="formation('<? echo $emp_id_mgr ;?>','<? echo $tnomm[1] ;?>')" > <? echo $tnomm[0];?> </a></td>
</tr>
<?
foreach($value as $key1 => $value1)
{
$tnom=explode("|",$value1);
?>
</tr>
<td></td>
<td> <a href="#" onClick="formation('<? echo $tnomm[1] ;?>','<? echo $tnom[1] ;?>')" ><img src="SommaireO" border="0"> <? echo $tnom[0];?> </a></td>
</tr>
<?
}
}
else
{
?>
<tr>
<td ><a href="#" onClick="subord('<? echo $emp_id_mgr ;?>','<? echo $tnomm[1] ;?>','<? echo $tnomm[0] ;?>')" > <img src="plusOrange" border="0"> </a></td>
<td><a href="#" onClick="formation('<? echo $emp_id_mgr ;?>','<? echo $tnomm[1] ;?>')" > <? echo $tnomm[0];?> </a></td>
</tr>
<?
}
}
?>
</table>
</td>
</tr>
<tr><td background="<?=$imagesPath?>header/fond_gris_b.gif"><img src="<?=$imagesPath?>header/spacer.gif" width="632" height="12"></td></tr>
</table>
</form>
<br>
</html>
<?
$db->DbClose();
?>