le 09/12/2010 à 18:50
Résultat d'un select qui ne s'affiche pas dans un tableau (<table></table>)
Hello.
Avec un peu de concatéation ce serait plus simple. initialise ton POST et sers-toi de $rix.
Essaye avec un truc comme ça :
@+...
Avec un peu de concatéation ce serait plus simple. initialise ton POST et sers-toi de $rix.
Essaye avec un truc comme ça :
<?php
if (isset($_POST["prix"])) $prix = $_POST["prix"];
?>
<!DOCTYPE html PUBLIC "-
//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-
strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" type="text/css" href="consultprix.css">
</head>
<body>
<div>
<h3>Choisir une tranche de prix :</h3>
<form method="post">
<p id="inf"><input type="radio" name="prix"
<?php
if ($prix == "1") {
echo 'checked="checked"';
}
?>
value="1" > < 200.000 € </p>
<input type="radio" name="prix"
<?php
if ($prix == "2") {
echo 'checked="checked"';
}
?>
value="2" > de 200.000 € à 300.000 € <br />
<p id="sup"><input type="radio" name="prix"
<?php
if ($prix == "3") {
echo 'checked="checked"';
}
?>
value="3" > > 300.000 € </p>
<input type="submit" name="afficher" value="Afficher"> <br />
</form>
</div>
<br />
<br />
<hr/>
<br />
<?php
if (isset($_POST["afficher"])) {
$conn = mysql_connect ("localhost","root","") or die ("Connexion impossible");
$base="umy63";
mysql_select_db("$base") or die ("Base inconnue");
print("Connexion réussie à la base :$base");
if (isset($prix)) {
if ($prix == "1") {
$requete='select b.idbien,b.detailbien,b.prixbien,t.nomtype, b.photobien from bien b, typebien t where b.idtype = t.idtype and b.prixbien < 200000;';
}
elseif ($prix == "2") {
$requete='select b.idbien,b.detailbien,b.prixbien,t.nomtype, b.photobien from bien b, typebien t where b.idtype = t.idtype and b.prixbien > 200000 and b.prixbien < 300000;';
}
else {
$requete='select b.idbien,b.detailbien,b.prixbien,t.nomtype, b.photobien from bien b, typebien t where b.idtype = t.idtype and b.prixbien > 300000;';
}
}
echo '<center>
<table width="100%" border="1">
<tr>
<td>Identificateur </td>
<td>Détail </td>
<td>Prix </td>
<td>NomType </td>
<td>Photo</td>
</tr>';
$result = mysql_query($requete,$conn);
if(mysql_errno()==0) {
if($result) {
while($row = mysql_fetch_array($result)) {
echo '<tr>
<td>'.$row["idbien"].'</td>
<td>'.$row["detailbien"].'</td>
<td>'.$row["prixbien"].'</td>
<td>'.$row["nomtype"].'</td>
<td>'.$row["photobien"].'</td>
</tr>';
}
echo '</table>';
mysql_free_result($result);
}
else {
echo "Pas de biens trouvé<br />";
}
}
else {
echo "Problème sur le select ...<br />";
echo mysql_errno().": ".mysql_error()."<br />";
}
mysql_close($conn);
}
?>
</body>
</html>
@+...