Bonjour,
j ai un fichier php qui me pemret d afficher les champs qui sont sur deux tables de ma base trier par premiere lettre
j ai fait un if pour afficher un message quand il n y a aucune entrees trouvé
mais ce message s affiche sur toutes les pages meme celle ou il n ya rien
Merci
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Catalogue</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body link="#000000" vlink="#FFFFFF" alink="#FFFFFF">
<div id="body">
<div id="menu-container"><b>
<a href="label.php?lettre=[0-9]" class="active"><span class="text">0-9</span></a> |
<a href="label.php?lettre=A" target="_self"><span class="text">A</span></a> |
<a href="label.php?lettre=B" target="_self"><span class="text">B</span></a> |
<a href="label.php?lettre=C" target="_self"><span class="text">C</span></a> |
<a href="label.php?lettre=D" target="_self"><span class="text">D</span></a> |
<a href="label.php?lettre=E" target="_self"><span class="text">E</span></a> |
<a href="label.php?lettre=F" target="_self"><span class="text">F</span></a> |
<a href="label.php?lettre=G" target="_self"><span class="text">G</span></a> |
<a href="label.php?lettre=H" target="_self"><span class="text">H</span></a> |
<a href="label.php?lettre=I" target="_self"><span class="text">I</span></a> |
<a href="label.php?lettre=J" target="_self"><span class="text">J</span></a> |
<a href="label.php?lettre=K" target="_self"><span class="text">K</span></a> |
<a href="label.php?lettre=L" target="_self"><span class="text">L</span></a> |
<a href="label.php?lettre=M" target="_self"><span class="text">M</span></a> |
<a href="label.php?lettre=N" target="_self"><span class="text">N</span></a> |
<a href="label.php?lettre=O" target="_self"><span class="text">O</span></a> |
<a href="label.php?lettre=P" target="_self"><span class="text">P</span></a> |
<a href="label.php?lettre=Q" target="_self"><span class="text">Q</span></a> |
<a href="label.php?lettre=R" target="_self"><span class="text">R</span></a> |
<a href="label.php?lettre=S" target="_self"><span class="text">S</span></a> |
<a href="label.php?lettre=T" target="_self"><span class="text">T</span></a> |
<a href="label.php?lettre=U" target="_self"><span class="text">U</span></a> |
<a href="label.php?lettre=V" target="_self"><span class="text">V</span></a> |
<a href="label.php?lettre=W" target="_self"><span class="text">W</span></a> |
<a href="label.php?lettre=X" target="_self"><span class="text">X</span></a> |
<a href="label.php?lettre=Y" target="_self"><span class="text">Y</span></a> |
<a href="label.php?lettre=Z" target="_self"><span class="text">Z</span></a></b>
</div>
<?php
include ('config.php');
include ('connexion.php');
echo '<table>
<tr>
<th>Label</th>
<th>Référence</th>
<th>Artiste</th>
<th>Album</th>
<th>Format</th>
<th>Modifier</th>
<th>Supprimer</th>
</tr>';
// paramètre reçu désignant le critère du nom du label recherché
$param1 = mysql_real_escape_string($_GET['lettre']);
//
$sql = "SELECT * FROM label
INNER JOIN contenu ON contenu.id_label = label.id_label
Where nom_label REGEXP '^$param1' order by nom_label, reference;
";
$req = mysql_query($sql);
while ($resultat = mysql_fetch_array($req))
{
echo '<tr>';
echo '<td>'.$resultat['nom_label'].'</td>';
echo '<td>'.$resultat['reference'].'</td>';
echo '<td>'.$resultat['artiste'].'</td>';
echo '<td>'.$resultat['album'].'</td>';
echo '<td>'.$resultat['format'].'</td>';
echo '<td><a href="formulaire_de_mise_a_jour.php?reference='.$resultat
['reference'].'">Modifier</a></td>';
echo '<td><a href="script_de_suppression.php?reference='.$resultat
['reference'].'">Supprimer</a></td>';
echo '</tr>';
}
echo '</table>';
$var = $resultat;
if($var == null)
{
echo ('<p align="center"> "Aucune référence trouvée" </p>');
}
?>
<div id="cat-footer"></div>
</body></html>
<?php
mysql_close();
?>
Afficher la suite
23 févr. 2009 à 15:08
J ai mis ca et pareil le aucune reference trouvée s affiche toujours partout
$var = $resultat;
if(empty($var))
{
echo ('<p align="center"> "Aucune référence trouvée" </p>');
}