Bonjour,
je pose le problème, j'ai un fichier classes.php qui contient ceci:
####################################################################
classe medecin
dans laquelle il y a une méthode getPatients()
cette méthode va me permettre de faire une requête sql sélectionnant toutes les données d'une table t_patients
public function getPatients()
{
$reponse = mysql_query("SELECT * FROM t_patients");
while ($donnees = mysql_fetch_array($reponse) )
{
$tab[0]= new patient($id, $nom, $prenom, $numSec, $dateOp, $commentaires);
return $tab;
}
}
###################################################################
classe patients
dans laquelle il y a:
class patient
{
private $id;
private $nom;
private $prenom;
private $numSec;
private $dateOp;
private $commentaires;
//----------------------------------------------------------------------------------------------
//constructeur
public function patient($id, $nom, $prenom, $numSec, $dateOp, $commentaires)
{
$this->id = $id;
$this->nom = $nom;
$this->prenom = $prenom;
$this->numSec = $numSec;
$this->dateOp = $dateOp;
$this->commentaires = $commentaires;
}
public function getId()
{
return $this->id;
}
public function getNomPatient()
{
return $this->nom;
}
public function getPrenom()
{
return $this->prenom;
}
public function getNumSec()
{
return $this->numSec;
}
public function getDateOp()
{
return $this->dateOp;
}
public function getObservation()
{
return $this->commentaires;
}
}
####################################################################
et un fichier getPatients.php
qui va appeler la fonction getPatients:
<?php
include_once("classes.php");
//instanciation dynamique
$get = new medecin($nom, $pwd, $pwdGeneral); //constructeur de la classe medecin
//connexion à la base
$get->connecterBdd();
//appel de la fonction getPatient
$tab=$get->getPatients();
//affichage des données du tableau
print ("Id <br>");
print ($tab[0]->getId());
print ("Nom <br>");
print($tab[0]->getNomPatient());
print ("Prénom <br>");
print($tab[0]->getPrenom());
print ("Numéro de sécurité sociale <br>");
print($tab[0]->getNumSec());
print ("Date d'opération<br>");
print($tab[0]->getDateOp());
print ("Observations<br>");
print($tab[0]->getObservation());
?>
#############################################
Le problème c'est que lorsque je teste ce fichier il ne me retourne juste:
Id
Nom
Prénom
Numéro de sécurité sociale
Date d'opération
Observations
je voudrais qu'il me retourne la première ligne de ma table t_patients (plutard je voudrais qu'il me retourne toutes les lignes)
COMMENT FAIRE??
merci
Configuration: Windows XP
Firefox 3.0.7