[php] Problème tableau: mêmes données affiché

Fermé
sylvain42 - 9 oct. 2007 à 09:45
 sylvain42 - 9 oct. 2007 à 10:16
Bonjour à tous,

j'ai donc créé un tableau en php, il affiche correctement, en fait il affiche les patients d'un hôpital et leur régime, mais le problème est que le même patient s'affiche plusieurs fois dans le tableau lorsque le patient a 2 régime (ex: sans sel, sans gras).
Le patient disposant d'un seul régime est, par contre, affiché une seule fois.

Voici mon script:

<HTML><HEAD>
<TITLE>Site de restauration</TITLE>

</HEAD>
<BODY>

<?php

require_once ("Connect.php");
require_once ("Connexion.php");
require_once ("ExecRequete.php");

$connexion = Connexion (NOM, PASSE, SERVEUR, BASE);
$nomreg = ExecRequete ("SELECT * FROM Regime", $connexion);
$resultat = ExecRequete ("SELECT civpat,nompat,prenpat,agepat,nomregime,Patient.codechambre,nomavers,libellelieu,nomcons,nomrem FROM Redime,Patient,Chambre,A,Lieu,Possede,Obtient WHERE Redime.codepat=Patient.codepat AND Chambre.codechambre=Patient.codechambre AND A.codepat=Patient.codepat AND Possede.codepat=Patient.codepat AND Obtient.codepat=Patient.codepat AND Lieu.codelieu=Patient.codelieu AND Chambre.nomunite='Unité 1 A'", $connexion);

echo "<CENTER><TABLE BORDER=4 CELLSPACING=2 CELLPADDING=2>"
. "<TR><TH>Civilité<TH>Nom<TH>Prénom<TH>Age<TH>N° Chambre<TH>Régime<TH>Aversion<TH>Consigne<TH>Remarque<TH>Plateau/Cantine";

while ($patient = ObjetSuivant ($resultat))
{
echo "<TR><TD>$patient->civpat<TD>$patient->nompat "
. "<TD>$patient->prenpat"
. "<TD>$patient->agepat"
. "<TD>$patient->codechambre"
. "<TD>$patient->nomregime"
. "<TD>$patient->nomavers"
. "<TD>$patient->nomcons"
. "<TD>$patient->nomrem"
. "<TD>$patient->libellelieu\n";
}

echo "</TABLE></CENTER>\n";
?>
</BODY></HTML>

Si vous voyez d'où vient le problème, merci pour votre aide...

Sylvain

2 réponses

Bonjour,
pense a fermer tes balise et quand tu utilises un tableau, ou un objet, il faut les concatener.
Dans ton cas :

echo "<tr><td>".$patient->civpat."</td><td>".$patient->nompat ."</td>'"
. "<td>".$patient->prenpat."</td>"
. "<td>".$patient->agepat."</td>"
. "<td>".$patient->codechambre."</td>"
. "<td>".$patient->nomregime."</td>"
. "<td>".$patient->nomavers."</td>"
. "<td>".$patient->nomcons."</td>"
. "<td>".$patient->nomrem."</td>"
. "<td>".$patient->libellelieu."</tr>\n";
}
0
Merci pour ta réponse, j'ai fait comme tu m'as dit, mais ça n'a rien changé à mon tableau.
0