$link = mysql_connect ($host,$user,$pass) or die ('Erreur : '.mysql_error());
mysql_select_db($db) or die ('Erreur :'.mysql_error());
$sql_recherche = (isset($_POST['recherche'])) ? " WHERE 'ref' = '".$_POST['recherche']."'" : "";
$select = "SELECT ref,nom,adr,rem,tech,date,tel FROM prestation_juillet_2006" .$sql_recherche;
$result = mysql_query($select,$link) or die ('Erreur : '.mysql_error());
$total = mysql_num_rows($result);
if($total) {
echo '<center><table border="0,5" bgcolor="#000080">'."\n";
/* première ligne on affiche les titres ref,nom,adr,rem,tech,date,tel dans 7 colonnes */
echo '<tr>';
echo '<td bgcolor="#0000FF" align="center"><b><font size="2" color="#FFFFFF">Réf Client</font></b></td>';
echo '<td bgcolor="#0000FF" align="center"><b><font size="2" color="#FFFFFF">Nom</font></b></td>';
echo '<td bgcolor="#0000FF" align="center"><b><font size="2" color="#FFFFFF">Adresse</font></b></td>';
echo '<td bgcolor="#0000FF" align="center"><b><font size="2" color="#FFFFFF">Remarques</font></b></td>';
echo '<td bgcolor="#0000FF" align="center"><b><font size="2" color="#FFFFFF">Téléphone client</font></b></td>' ;
echo '<td bgcolor="#0000FF" align="center"><b><font size="2" color="#FFFFFF">Date</font></b></td>' ;
echo '<td bgcolor="#0000FF" align="center"><b><font size="2" color="#FFFFFF">Nom du technicien</font></b></td>' ;
echo '</tr>'."\n";
// lecture et affichage des résultats sur 7 colonnes, 1 résultat par ligne.
while($row = mysql_fetch_array($result)) {
echo '<tr>';
echo '<td bgcolor="#FFFFFF"><font size="2">'.$row["ref"].'</font></td>';
echo '<td bgcolor="#FFFFFF"><font size="2">'.$row["nom"].'</font></td>';
echo '<td bgcolor="#FFFFFF"><font size="2">'.$row["adr"].'</font></td>';
echo '<td bgcolor="#FFFFFF"><font size="2">'.$row["rem"].'</font></td>';
echo '<td bgcolor="#FFFFFF"><font size="2">'.$row["tel"].'</font></td>';
echo '<td bgcolor="#FFFFFF" nowrap><font size="2">'.$row["date"].'</font></td>';
echo '<td bgcolor="#FFFFFF"><font size="2">'.$row["tech"].'</font></td>';
echo '</tr>'."\n";
}
echo '</table></center>'."\n";
// fin du tableau.
}
else echo 'Pas de résultat suivant votre recherche.';
// on libère le résultat
mysql_free_result($result);
?>
Partager