Bonjour,

J'essaie d'utiliser "NATURAL JOIN" voici ma requète :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
SELECT *   from attribuer NATURAL JOIN (personnel)
            order by attribuer.id_aff desc
la table "attribuer" :id_perso id_aff nb_heures
la table "personnel" : id_perso nom_perso prenom

(donc ça se joint naturellement via le champ id_perso)

le code php :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
echo " <font class=red><b>ID : ".$data["id_aff"]."&nbsp;</b></font><b> ".$data["etat"]."&nbsp;</b>
<form action=./../modifier/pre_modif.php method=post >
                    <input type=hidden name=id_aff  value= ".$data['id_aff']." >
                    <input class=bouton type=submit name=envoie value=Ouvrir >
                </form>
<b> Agent :</b> ".$data["prenom"]." ".$data["nom_perso"]."  <sup>".$data["id_perso"]."</sup>
 &nbsp  &nbsp <font class=mar><b>Heures</b> : ".$data["nb_heures"]."</font>
  &nbsp  &nbsp <font class=vert><b>description</b> : ".$data["desc"]."</font>
ça marche, avec parfois des doublons, cad par exemple ça va m'afficher

ID 1994 Agent : Michel ATBA 31 Heures : 12 description : toto
ID 1993 Agent : Michel ATBA 31 Heures : 1 description : titi
ID 1993 Agent : Michel ATBA 31 Heures : 3 description : titi

Que dois-je rajouter pour éviter ça, cad dans l'exemple avoir ce qui suit : ?

ID 1994 Agent : Michel ATBA 31 Heures : 12 description : toto
ID 1993 Agent : Michel ATBA 31 Heures : 4 ( 1+3) description : titi

(sachant que ID 1994 et 1993 correspond à l'ID_aff qui ne correspond qu'à une seule affaire)


Cordialement,
Philippe Rivière