j'ai une table que famille . qui permet d'enregistrer des famille sur un site . je dois faire une requète pour afficher :
- matricule du chef de famille
- le nom du chef de famille
- le sexe du chef de famille
- l'age de chef de famille
- le taille de la famille (nombre de personnes)
-composition de la famille ( F (les filles ) ,H (les garçons , E (les enfants))
voici la structure de la base de donnée :
CREATE TABLE IF NOT EXISTS `famille` (
`id_famillet` int(15) NOT NULL AUTO_INCREMENT,
`lesite` varchar(80) COLLATE utf8_unicode_ci NOT NULL,
`matricule` int(15) NOT NULL,
`nom1` varchar(150) COLLATE utf8_unicode_ci NOT NULL,
`lien1` varchar(30) COLLATE utf8_unicode_ci NOT NULL,
`sexe1` varchar(10) COLLATE utf8_unicode_ci NOT NULL,
`age1` varchar(30) COLLATE utf8_unicode_ci NOT NULL,
`etat1` varchar(30) COLLATE utf8_unicode_ci NOT NULL,
`niveau1` varchar(30) COLLATE utf8_unicode_ci NOT NULL,
`nationalite1` varchar(30) COLLATE utf8_unicode_ci NOT NULL,
PRIMARY KEY (`id_enfant`),
UNIQUE KEY `id_enfant` (`id_enfant`),
UNIQUE KEY `id_enfant_3` (`id_enfant`),
KEY `id_enfant_2` (`id_enfant`),
KEY `id_enfant_4` (`id_enfant`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1835 ;
voici le code que j'ai fait mais je sais pas comment afficher :
- le taille de la famille (nombre de personnes)
-composition de la famille ( F (les filles ) ,H (les garçons , E (les enfants))
Code PHP :
<?php
$_POST["nom1"]=""; $_POST["sexe1"]=""; $_POST["age1"]=""; $_POST["lesite"]=""; //$_POST["matricule="]="";
$nom1=trim($_POST["nom1"]); $nom1=trim($_POST["sexe1"]); $nom1=trim($_POST["sexe1"]); $nom1=trim($_POST["lesite"]); //$matricule=trim($_POST["matricule"]);
$color=array('#333333','#999999');
$i=0;
//On se connecte à la base de donnée
include("connection.php");
// on crée la requête SQL
$sql = "SELECT lesite,matricule,nom1,sexe1,age1 FROM enfant
WHERE
lien1 = 'CM/PE.....1'
ORDER BY matricule ASC";
// on envoie la requête
$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error());
$res = mysql_num_rows($req); // 4
?>
<!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;
}
-->
</style>
</head>
<body>
<div align="center">
<h1 align="center" class="Style6">>>> FICHE D'IDENTIFICATION <<< </h1>
</div>
<p> </p>
<table width="767" border="0" align="center" cellspacing="2" bgcolor="#00FF00">
<tr bgcolor="#999999">
<th bgcolor="#00FF00" scope="row"><div align="left"></div>
</td> </tr>
<tr bgcolor="#999999">
<th width="110" rowspan="2" scope="row"><span class="Style3">MATRICULE</span></th>
<th width="48" rowspan="2" scope="row"><span class="Style3">Site</span></th>
<th width="99" rowspan="2" scope="row"><span class="Style3">NOM ET PRENOMS </span></th>
<th width="61" rowspan="2" scope="row"><span class="Style3">SEXE</span></th>
<th width="55" rowspan="2" scope="row"><span class="Style3">AGE</span></th>
<th width="91" rowspan="2" scope="row"><span class="Style3">TAILE DU MENAGE </span></th>
<th colspan="3" scope="row"><span class="Style3">COMPOSITION DE MENAGE </span></th>
<th width="147" rowspan="2" scope="row"><span class="Style3">TEL</span></th>
</tr>
<tr bgcolor="#999999">
<th scope="row"><span class="Style3">H</span></th>
<th scope="row"><span class="Style3">F</span></th>
<th scope="row"><span class="Style3">E</span></th>
</tr>
<?php
while ($liste_etu=mysql_fetch_assoc($req)) {
$j=$i%2;
?>
<tr bgcolor=#33FFFF>
<td height="24" bgcolor="#FFFFFF"><?php echo $liste_etu['matricule'] ?></td>
<td bgcolor="#FFFFFF"><?php echo $liste_etu['lesite'] ?></td>
<td bgcolor="#FFFFFF"><?php echo $liste_etu['nom1'] ?></td>
<td bgcolor="#FFFFFF"><?php echo $liste_etu['sexe1'] ?></td>
<td bgcolor="#FFFFFF"><?php echo $liste_etu['age1'] ?></td>
<td bgcolor="#FFFFFF"><input name="textfield5" type="text" size="5" /></td>
<td width="45" bgcolor="#FFFFFF"><input name="textfield" type="text" size="5" /></td>
<td width="34" bgcolor="#FFFFFF"><input name="textfield2" type="text" size="5" /></td>
<td width="35" bgcolor="#FFFFFF"><input name="textfield3" type="text" size="5" /></td>
<td bgcolor="#FFFFFF"><input type="text" name="textfield4" /></td>
</tr>
<?php
}
?>
</table>
</body>
</html>