Select in MYSQL cu date din form prin GET
Scris: Mar Feb 28, 2012
Salut am urmatorul cod :
Acest cod ar trebui sa filtreze produsele din anumite categorii dar cand dai submit nu se executa nimic...nu mai stiu ce sa ii fac daca poate sa imi zica cineva care e problema? Ms mult!
Cod: Selectaţi tot
<form method="get" action="">
<select name="categorie">
<option>nokia</option>
<option>samsung</option>
<option>lg</option>
<option>philips</option>
</select>
<input type="submit" value="Filtreaza!" name="subfil" />
</form>
<?
if(!isset($_GET['subfil']))
{
$sql = "SELECT * FROM produse WHERE categorie='$categorie'";
$res = mysql_query($sql) or die("$sql");
$categorie = $_GET['categorie'];
while ($row = mysql_fetch_array($res))
{
$produs= $row["produs"];
$id = $row["id"];
$pret = $row["pret"];
$detalii = $row["detalii"];
echo'<table width="20px" align="center" style="float:left; padding-left:5px; margin-left:28px; margin-bottom:9px; margin-top:20px; margin-right:12px; background-color:#F3F3F3; border:solid 1px #ccc; -webkit-border-radius:8px; -moz-border-radius:8px; -ms-border-radius:8px;">
<th width="100" rowspan="3"><img src="produse/'.$id.'.jpg" width="100" height="100"/></th><td width="120">'. $produs .'
</tr>
<tr>
<td>Pret: '.$pret.' Lei</td>
</tr>
<tr>
<td height="43"><a href="produse.php?produs='.$id.'"><img src="detalii.png" border="0" title="Detalii '.$produs.'"/></a></td>
</tr></table> ';
}
}
?>