Je vous remercie pour ta réponse.J'ai essayé la recurcivité mais je ne sais comment procéder pour afficher :
Total : ........ Niveau :.......
Voici mon code qui me sert à afficher le contenu de ma base :
<?php
#Paramétres de configuration
$hostname = "localhost";
$database = "test_arbre";
$Username = "root";
$password = "";
$Dataconnection = mysql_connect($hostname, $Username, $password) or die(mysql_error());
// paramétre mysql et chargement de la classe bdd.
mysql_select_db($database, $Dataconnection);
?>
<html>
<head>
<title>Document sans nom</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
.label {
font-family: "Trebuchet MS", "Tw Cen MT", "Tw Cen MT Condensed";
font-weight: bold;
color: #FFFFFF;
font-size: small;
}
.label1 {
font-family: "Trebuchet MS", "Tw Cen MT", "Tw Cen MT Condensed";
font-weight: bold;
color: #FF0000;
font-size: small;
}
.label2 {
font-family: "Trebuchet MS", "Tw Cen MT", "Tw Cen MT Condensed";
font-weight: bold;
color: #000000;
font-size: small;
}
-->
</style>
</head>
<BODY leftMargin=0 topMargin=0 marginheight="0" marginwidth="0">
<form name="forgotpass" method="post" action="">
<table width="400" border="0" bgcolor="#FFCC66" align="center" cellspacing="5" cellpadding="5">
<td width="200" align="right" class="label2">Selectionnez le Pseudo :</td>
<td width="100">
<?
$result=mysql_query("select nom_exemple
from tab_exemple order by id_exemple",$Dataconnection);
echo"<select name=\"usernam\">";
while (list($affichage)=mysql_fetch_array($result)){
echo"<option>$affichage</option>";
}
echo"</select>";
?>
</td>
<td width="100"><input name="afficher" type="submit" value="Afficher >>" style=" BORDER-RIGHT: #999999 1px solid;
BORDER-TOP: #999999 1px solid;
FONT-SIZE: 11px;
BACKGROUND: #336699;
BORDER-LEFT: #999999 1px solid;
COLOR: #cc3300;BORDER-BOTTOM: #999999 1px solid;
FONT-FAMILY: Helvetica;
TEXT-DECORATION: none">
</td>
</tr>
</table>
</form>
</body>
<?php
if(isset($_POST['afficher'])){
$nom = $_POST['usernam'];
$result_global=mysql_query("select code_exemple
from tab_exemple
where nom_exemple='$nom'"
);
list($code_depart)=mysql_fetch_array($result_global);
echo"Code Pere : $code_depart<br>";
affichage_branche($code_depart);
}
function affichage_branche($code_depart) {
$niveau1 =0;
$nbfils =0;
$nbfils1 =0;
$num1 =0;
$result_query = mysql_query("select code_noeud,niveau_noeud
from tab_noeud
where parent_noeud='$code_depart'"
);
while (list($code,$niveau)=mysql_fetch_array($result_query)) {
$num = mysql_num_rows($result_query);
$tab=str_repeat(".",$niveau*4);
echo "<li>".$tab."Code : ".$code." Nbre Fils : ".$num." Niveau :".$niveau;
affichage_branche($code);
$num1 = $num;
$niveau1 = $niveau;
}
if($niveau1 == $niveau){}
else{
$tab=str_repeat(".",$niveau1*4);
echo "<br><li>$tab T Nbre Fils : ".$num1." Niveau :".$niveau1;
}
}
?>