Sunday, 11 August 2013

How to use "any" in select list of a form to work in mysql?

How to use "any" in select list of a form to work in mysql?

I have form which use below codes:
<select name="ptype">
<option selected="selected" value="">Any</option>
<option value="1">1</option>
<option value="2">2</option>
</select>
now, how can the php page process the "Any" field in mysql. I tried below
code, but didnot worked on process page:
$q=mysql_query("SELECT * FROM `listing` WHERE ptype='{$_POST['ptype']}'");
echo mysql_error();
while($r=mysql_fetch_array($q)){
}
what may be the error ? or how to use "any" value ?

No comments:

Post a Comment