salut . j'ai une base de donnée qui contient la table
victime (matricule,questionnaire,nom,region,village,tel)
enfant(id_enfant,matricule,nom1,lien1,sexe1,age1)
j'ai pas pu lier les deux tables . alors pour retrouver les enfants de la victime j'ai crée les champs questionnaire(numero qui identifie la victime) et matricule(numero qui identifie les enfants de la victime)
donc à partir de questionnaire et matricule je retrouve les enfants de la victime .
alors je veux avoir les informations concernant le victime et ses enfants dans un page à partir du numéro(questionnaire=matricule) dans 2 tableaux différents .
le premier tableau affiche bien la victime mais le deuxième tableau n'affiche pas les enfants.
merci de bien vouloir m'aider.
voici mon code :
Code PHP :
<?php
if(isset($_POST['questionnaire']) && !empty($_POST['questionnaire'])){
include("connection.php");
$id=(int)$_POST['questionnaire'];
$id=mysql_real_escape_string($id);
$sql = "SELECT DISTINCT questionnaire,nom,region,village,tel FROM victime where questionnaire='".$id."'";
$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error());
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Document sans titre</title>
<style type="text/css">
<!--
.Style3 {color: #FFFFFF}
.Style6 {
color: #0000FF;
font-style: italic;
font-weight: bold;
}
.Style11 {color: #0000FF; font-weight: bold; }
.Style14 {color: #990000}
-->
</style>
</head>
<body>
<form id="form1" name="form1" method="post" action="">
<table width="333" border="0" align="center" bgcolor="#FFFFCC">
<tr>
<td bgcolor="#FF00FF"><A HREF="enregistrement.php" TITLE="click pour enregistrer vos enfants!!! !!!!" class="Style17 Style3"><strong>Accueil</strong></a></td>
<td bgcolor="#FF00FF"> </td>
</tr>
<tr>
<td width="195">Numero du Questionnaire
<input type="text" name="questionnaire" /></td>
<td width="128"><input type="submit" name="Submit" value="RECHERCHER" /></td>
</tr>
</table>
</form>
<div align="center">
<h1 align="center" class="Style6"> </h1>
</div>
<p> </p><center>
<fieldset style="width: 650px;" ><legend><span class="Style11">CHEF DE MENAGE</span></legend>
<table width="585" border="0" align="center" cellspacing="1" bordercolor="#333333" bgcolor="#FFFFCC">
<tr bgcolor="#999999">
<th bgcolor="#FFFFCC" scope="row"><div align="left"></div></th>
<td width="103" bgcolor="#FFFFCC"><div align="right"></div></td>
</tr>
<tr bgcolor="#999999">
<th width="256" bgcolor="#FFFFCC" scope="row"><span class="Style14">NOM ET PRENOMS </span></th>
<th width="103" bgcolor="#FFFFCC" scope="row"><span class="Style14">REGION </span></th>
<th width="129" bgcolor="#FFFFCC" scope="row"><span class="Style14">VILLAGE </span></th>
<th width="84" bgcolor="#FFFFCC" scope="row"><span class="Style14">TEL </span></th>
</tr>
<?php
while ($liste_etu=mysql_fetch_assoc($req)) {
$j=$i%2;
?>
<tr bgcolor=#FFFFCC>
<td bgcolor="#CCCCCC"><input type="text" name="textfield" value="<?php echo $liste_etu['nom'] ?>"/></td>
<td bgcolor="#CCCCCC"><input type="text" name="textfield" value="<?php echo $liste_etu['region'] ?>"/></td>
<td bgcolor="#CCCCCC"><input type="text" name="textfield" value="<?php echo $liste_etu['village'] ?>"/></td>
<td bgcolor="#CCCCCC"><input type="text" name="textfield" value="<?php echo $liste_etu['tel'] ?>"/></td>
</tr>
<?php
}
?>
</table>
</fieldset>
</center>
</p><center>
<fieldset style="width: 650px;" ><legend><span class="Style11">MEMBRES</span></legend>
<table width="585" border="0" align="center" cellspacing="1" bordercolor="#333333" bgcolor="#FFFFCC">
<tr bgcolor="#999999">
<th bgcolor="#FFFFCC" scope="row"><div align="left"></div></th>
<td width="103" bgcolor="#FFFFCC"><div align="right"></div></td>
</tr>
<tr bgcolor="#999999">
<th width="256" bgcolor="#FFFFCC" scope="row"><span class="Style14">NOM ET PRENOMS </span></th>
<th width="103" bgcolor="#FFFFCC" scope="row"><span class="Style14">LIEN </span></th>
<th width="129" bgcolor="#FFFFCC" scope="row"><span class="Style14">SEXE </span></th>
<th width="84" bgcolor="#FFFFCC" scope="row"><span class="Style14">AGE </span></th>
</tr>
<?php
if(isset($_POST['matricule']) && !empty($_POST['matricule'])){
$id=(int)$_POST['matricule'];
$id=mysql_real_escape_string($id);
$sql = "SELECT DISTINCT matricule,nom1,lien1,sexe1,age1 FROM enfant where matricule='".$questionnaire."'";
$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error());
while ($liste_etu=mysql_fetch_assoc($req)) {
$j=$i%2;
?>
<tr bgcolor=#FFFFCC>
<td bgcolor="#CCCCCC"><input type="text" name="textfield" value="<?php echo $liste_etu['nom1'] ?>"/></td>
<td bgcolor="#CCCCCC"><input type="text" name="textfield" value="<?php echo $liste_etu['lien1'] ?>"/></td>
<td bgcolor="#CCCCCC"><input type="text" name="textfield" value="<?php echo $liste_etu['sexe1'] ?>"/></td>
<td bgcolor="#CCCCCC"><input type="text" name="textfield" value="<?php echo $liste_etu['age1'] ?>"/></td>
</tr>
<?php
}
}
?>
</table>
</fieldset>
</center>
</body>
</html>