par
albat » 29 mai 2005, 12:17
Le même, un petit peu allégé...
<?php
// On construit la requête de base
$Requete = "SELECT * FROM biens WHERE 1 = 1";
// On ajoute des clauses si des paramètres ont été envoyés
if ($prix != "") $Requete .= " AND prix = '".$prix."'";
if ($ville != "") $Requete .= " AND ville = '".$ville."'";
if ($typ != "") $Requete .= " AND typ = '".$typ."'";
if ($surf != "") $Requete .= " AND surf = '".$surf."'";
if ($et != "") $Requete .= " AND et = '".$et."'";
?>
<table class="texte" width="96%"" border="1" bordercolor="#FFE26F" cellspacing="0" align="center">
<tr bgcolor="#FFCB1A">
<td width="3%" align="center">S.</td>
<td width="3%" align="center">n°</td>
<td width="6%" align="center">Ville</td>
<td width="4%" align="center">Type</td>
<td width="5%" align="center">Prix</td>
<td width="3%" align="center">Surf</td>
<td width="3%" align="center">Photo 1</td>
<td width="3%" align="center">Photo 2</td>
<td width="3%" align="center">Photo 3</td>
<td width="3%" align="center">Photo 4</td>
<td width="3%" align="center">Editer</td>
</tr>
<?php
// On exécute la requête
$recherche = mysql_query($Requete);
// On récupère le résultat de la requête
while ($Result = mysql_fetch_array($recherche))
{
?>
<tr>
<td width="3%" align="center" bgcolor="#FFECAA"><input type="button" value="S" style="FONT-FAMILY: Verdana; FONT-SIZE: 8pt" OnClick="window.location='../../photos/photos/purge_a.php?num=<?php echo($Result['num']); ?> && tof1=<?php echo($Result['tof1']); ?> && tof2=<?php echo($Result['tof2']); ?> && tof3=<?php echo($Result['tof3']); ?> && tof4=<?php echo($Result['tof4']); ?>'"></td>
<td width="3%" align="center"><?php echo(stripslashes($Result['num'])); ?> </td>
<td width="6%" align="center"><?php echo(stripslashes($Result['ville'])); ?> </td>
<td width="4%" align="center"><?php echo(stripslashes($Result['typ'])); ?> </td>
<td width="5%" align="center"><?php echo(stripslashes($Result['prixe'])); ?> </td>
<td width="3%" align="center"><?php echo(stripslashes($Result['surf'])); ?> </td>
<td width="3%" align="center"bgcolor="#FFFFE8" ><img height="60" src="../../photos/photos/".stripslashes($Result['tof1']).""> </td>
<td width="3%" align="center"bgcolor="#FFFFE8" ><img height="60" src="../../photos/photos/".stripslashes($Result['tof2']).""> </td>
<td width="3%" align="center"bgcolor="#FFFFE8" ><img height="60" src="../../photos/photos/".stripslashes($Result['tof3']).""> </td>
<td width="3%" align="center"bgcolor="#FFFFE8" ><img height="60" src="../../photos/photos/".stripslashes($Result['tof4']).""> </td>
<td width="3%" align="center" bgcolor="#FFF9E1"><input type="button" value="E." style="FONT-FAMILY: Verdana; FONT-SIZE: 8pt" OnClick="window.location='detail_a.php?num=<?php echo($Result['num']); ?>'"></td>
</tr>
<?php
}
?>
</table>
NB : Je me suis permis de remplacer la clause
WHERE true = 'true' par
WHERE 1 = 1
car même si elle fonctionne, cette écriture ne me paraît pas très académique...
Suggestions :
- Tu peux virer tous tes
width="...%", ne serait-ce que parce que la largeur totale de tes cellules est de 39%.
- En utilisant les CSS, tu simplifierais beaucoup le code d'affichage de ton tableau
Le même, un petit peu allégé... ;)
[php]<?php
// On construit la requête de base
$Requete = "SELECT * FROM biens WHERE 1 = 1";
// On ajoute des clauses si des paramètres ont été envoyés
if ($prix != "") $Requete .= " AND prix = '".$prix."'";
if ($ville != "") $Requete .= " AND ville = '".$ville."'";
if ($typ != "") $Requete .= " AND typ = '".$typ."'";
if ($surf != "") $Requete .= " AND surf = '".$surf."'";
if ($et != "") $Requete .= " AND et = '".$et."'";
?>
<table class="texte" width="96%"" border="1" bordercolor="#FFE26F" cellspacing="0" align="center">
<tr bgcolor="#FFCB1A">
<td width="3%" align="center">S.</td>
<td width="3%" align="center">n°</td>
<td width="6%" align="center">Ville</td>
<td width="4%" align="center">Type</td>
<td width="5%" align="center">Prix</td>
<td width="3%" align="center">Surf</td>
<td width="3%" align="center">Photo 1</td>
<td width="3%" align="center">Photo 2</td>
<td width="3%" align="center">Photo 3</td>
<td width="3%" align="center">Photo 4</td>
<td width="3%" align="center">Editer</td>
</tr>
<?php
// On exécute la requête
$recherche = mysql_query($Requete);
// On récupère le résultat de la requête
while ($Result = mysql_fetch_array($recherche))
{
?>
<tr>
<td width="3%" align="center" bgcolor="#FFECAA"><input type="button" value="S" style="FONT-FAMILY: Verdana; FONT-SIZE: 8pt" OnClick="window.location='../../photos/photos/purge_a.php?num=<?php echo($Result['num']); ?> && tof1=<?php echo($Result['tof1']); ?> && tof2=<?php echo($Result['tof2']); ?> && tof3=<?php echo($Result['tof3']); ?> && tof4=<?php echo($Result['tof4']); ?>'"></td>
<td width="3%" align="center"><?php echo(stripslashes($Result['num'])); ?> </td>
<td width="6%" align="center"><?php echo(stripslashes($Result['ville'])); ?> </td>
<td width="4%" align="center"><?php echo(stripslashes($Result['typ'])); ?> </td>
<td width="5%" align="center"><?php echo(stripslashes($Result['prixe'])); ?> </td>
<td width="3%" align="center"><?php echo(stripslashes($Result['surf'])); ?> </td>
<td width="3%" align="center"bgcolor="#FFFFE8" ><img height="60" src="../../photos/photos/".stripslashes($Result['tof1']).""> </td>
<td width="3%" align="center"bgcolor="#FFFFE8" ><img height="60" src="../../photos/photos/".stripslashes($Result['tof2']).""> </td>
<td width="3%" align="center"bgcolor="#FFFFE8" ><img height="60" src="../../photos/photos/".stripslashes($Result['tof3']).""> </td>
<td width="3%" align="center"bgcolor="#FFFFE8" ><img height="60" src="../../photos/photos/".stripslashes($Result['tof4']).""> </td>
<td width="3%" align="center" bgcolor="#FFF9E1"><input type="button" value="E." style="FONT-FAMILY: Verdana; FONT-SIZE: 8pt" OnClick="window.location='detail_a.php?num=<?php echo($Result['num']); ?>'"></td>
</tr>
<?php
}
?>
</table>
[/php]
NB : Je me suis permis de remplacer la clause [b]WHERE true = 'true'[/b] par [b]WHERE 1 = 1[/b]
car même si elle fonctionne, cette écriture ne me paraît pas très académique... ;)
Suggestions :
- Tu peux virer tous tes [b]width="...%"[/b], ne serait-ce que parce que la largeur totale de tes cellules est de 39%.
- En utilisant les CSS, tu simplifierais beaucoup le code d'affichage de ton tableau