Hi,
I am trying to create a query which allows a user to look up property by type using a dropdown list. I am using a variable in the SELECT query to check if there are any records in the database and print them on screen.
The following code accepts a variable (selected from a dropdown list) and uses it in a query. In this example the variable’s value is “type” – without the quotes.
Eg:The PHP code:
$type = $_POST[‘type’]; (I am storing the option from the ‘type’ drop down list in this variable)
Code:
The queries i have tried:
$query = mysql_query(“SELECT * FROM tbl_property WHERE type=’$type’ “);
$query = (“SELECT * FROM tbl_property
WHERE type
==”.””.$type."");
$query = “SELECT COUNT() FROM tbl_property WHERE type==’" . $type . “’”;
$query = mysql_query("SELECT COUNT() FROM tbl_property WHERE type=”" . $type."");
$result = mysql_query($query)or die("Error in query: ". mysql_error());
The HTML form:
I would really appreciate any help as i am really stuck on this problem. Thanks.