Donc je suis entrain d'essayer de créer un tableau croisé dynamique sous PHP / MySQL et je n'ai malheuresement pas trouvé de tuto à ce sujet ou je n'ai pas su chercher.
Voici une image du tableau :
http://profile.imageshack.us/user/arkil ... phpjf0.png
La Base de Données :
* Table "medicament" qui contient 2 champs nummedic & nommedic.
* Table "patient" qui contient 5 champs
- numpatient (N° Auto)
- nompatient
- numordo (numéro de l'ordonnance saisi manuellement)
- medic1 (correspond au nom du médicament précris, incrémenté par une liste déroulante qui est basé sur la base médicament)
- qtemedic1 (qui est censé représenter la quantité du medicament).
Ce qui est fait :
- Gestion complete d'ajout/modification/ suppression des médicaments et des patients.
- Alors le tableau est crée et il m'affiche bien automatiquement les patients et médicaments si je l'ai ajoute par un formulaire, pas de souci la dessus.
Mon probléme :
Exemple je préscris à GOMIS Iness 3X du Caelyx 50 mg *
Comment faire pour que la quantité (3) s'affiche automatiquement sur la ligne correspondant au patient et sur la colone correspondant au médicament ?
Voici mon code PHP :
<?php require_once('Connections/connect_pharma.php'); ?>
<?php
mysql_select_db($database_connect_pharma, $connect_pharma);
$query_aff_medic = "SELECT nommedic FROM medicament ORDER BY nommedic ASC";
$aff_medic = mysql_query($query_aff_medic, $connect_pharma) or die(mysql_error());
$row_aff_medic = mysql_fetch_assoc($aff_medic);
$totalRows_aff_medic = mysql_num_rows($aff_medic);
mysql_select_db($database_connect_pharma, $connect_pharma);
$query_Req_recuppatient = "SELECT nompatient, numordo FROM patient ORDER BY numordo ASC";
$Req_recuppatient = mysql_query($query_Req_recuppatient, $connect_pharma) or die(mysql_error());
$row_Req_recuppatient = mysql_fetch_assoc($Req_recuppatient);
$totalRows_Req_recuppatient = mysql_num_rows($Req_recuppatient);
mysql_select_db($database_connect_pharma, $connect_pharma);
$query_req_insertordo = "SELECT * FROM patient, medicament WHERE patient.medic1 = medicament.nommedic";
$req_insertordo = mysql_query($query_req_insertordo, $connect_pharma) or die(mysql_error());
$row_req_insertordo = mysql_fetch_assoc($req_insertordo);
$totalRows_req_insertordo = mysql_num_rows($req_insertordo);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" type="text/css" href="pharmacss.css">
<title>Grille Chimio-Pharmacie</title>
<style type="text/css">
<!--
.Style3 {color: #FF0000}
-->
</style>
</head>
<body>
<p align="center"><font color="#339966"><B>Affichage du tableau de Chimio</B></font></p>
<table border="1">
<td valign="bottom">Nom / Prénom du Patient</td>
<td><div class="Style3" id="verticale">Numéro Ordonnance</div></td>
<?php do { ?>
<td><div id="verticale"><?php echo $row_aff_medic['nommedic']; ?></div></td>
<?php } while ($row_aff_medic = mysql_fetch_assoc($aff_medic)); ?>
<?php do { ?>
<tr>
<td valign="bottom"><?php echo $row_Req_recuppatient['nompatient']; ?></td>
<td><?php echo $row_Req_recuppatient['numordo']; ?></td>
<?php } while ($row_Req_recuppatient = mysql_fetch_assoc($Req_recuppatient)); ?>
<?php do { ?>
<td><?php echo $row_req_insertordo['qtemedic1']; ?></td>
<?php } while ($row_req_insertordo = mysql_fetch_assoc($req_insertordo)); ?>
<td> </td>
<tr>
</tr>
</table>
<p align="center"><a href="saisimedic.php"><img src="images/fleche.png" width="12" height="12"> Gérer les Médicaments <img src="images/flecheinv.png" width="12" height="12"></a></p>
<p align="center"><a href="index.php"><img src="images/fleche.png" width="12" height="12"> Retour Index <img src="images/flecheinv.png" width="12" height="12"></a> </p>
</body>
</html>
<?php
mysql_free_result($aff_medic);
mysql_free_result($Req_recuppatient);
mysql_free_result($req_insertordo);
?>
Je pense que mon probléme doit venir de la construction de mon tableau ou les boucles sont mal gérés ?Je suis débutant en PHP, j 'ai déjà réussi à faire pas mal de truc mais la je séche sérieusement.
En vous remerciant par avance pour vos réponses.