I have a Form with the code <form action="search.php" method="post"> in a search.html page. When you click on the submit button, it runs search.php, querying the database and displaying the results.
This is the (I believe)relevant code I have in the search.php
$result= mysql_query("SELECT * FROM list WHERE
id = '$_POST[id]' AND gender = '$_POST[gender]' ORDER BY id");
Currently it searches fine, if you enter correct data in all fields. However if you leave a field blank you receive no results as it is essentially searching for entries that have no data for the field that was left blank. Is there a way to set it so that if nothing is entered into the form, or some parts of the form, then that condition is ignored?
For example, if you enter in the id 001 and male you get the one result, however if you just put male, you receive no results whereas I would like it to return with all the entries that have the gender listed as male.
Also, I have been having some difficulties with wild cards and where to put them. For example, I would like to be able to put 1 in the id form and get results where the id is 001 or 010 or 014, etc.
Thanks!