Friends this is the simple php code.
<?php
$dbHost = 'localhost'; // localhost will be used in most
cases
// set these to your mysql database username and
password.
$dbUser = 'root';
$dbPass = '12345';
$dbDatabase = 'member'; // the database you put the
table into.
$con = mysql_connect($dbHost, $dbUser, $dbPass) or
trigger_error("Failed to connect to MySQL Server. Error:
" . mysql_error());
mysql_select_db($dbDatabase) or trigger_error("Failed
to connect to database {$dbDatabase}. Error: " . mysql_
error());
?>
<?php
if(isset($_POST['submit']))
{
$sex = $_POST['sex'];
$district = $_POST['district'];
$age1 = ($_POST['age1']);
$age2 = ($_POST['age2']);
} elseif(isset($_GET['submit']))
{
$sex = $_GET['sex'];
$district = $_GET['district'];
$age1 = ($_GET['age1']);
$age2 = ($_GET['age2']);
}
if ($sex == 'All' && $district == '$district' && $age1 == '$
age1' && $age2 == '$age2') {
$result = mysql_query("select * from user where (Sex =
'Male') AND (Sex = 'Female') AND (Age BETWEEN '$
age1' AND '$age2') || (District = '$district') ");
} else if ($sex == 'Female' && $district == '$district' && $
age1 == '$age1' && $age2 == '$age2') {
$result = mysql_query("select * from user where (Sex =
'Female') AND (Age BETWEEN '$age1' AND '$age2') ||
(District = '$district')");
} else {
$result = mysql_query("select * from user where (Sex =
'Male') AND (Age BETWEEN '$age1' AND '$age2') ||
(District = '$district')");
}
$rows = mysql_num_rows($result);
if($rows){
$i=0;
?>
<?php
while($row= mysql_fetch_array($result))
{
//$row['Photo'] = "<img src="/user_image/ .
$row['Photo']; ""/>
?>
<table width="100%">
<tr width="150" class="label">
<td height="21" colspan="2" > <div
align="center" style="font:'Times New Roman', Times,
serif; font-size:15px;">
<div align="left">Sex:
<?php echo $row['Sex']; ?>
</div>
</div>
<div align="center"
style="font:'Times New Roman', Times, serif; font-
size:15px;">
<div align="left">District:
<?php echo $row['District']; ?>
</div>
</div>
</td>
</tr>
</table>
<?php
}}
?>
and this is Form code.
<html>
<title>My Simple Search Form</title>
<body>
<form action="<?php echo $_SERVER['PHP_SELF'];?>"
method="post">
<tr>
<td><label>Seeking:</label></td>
<td> <select name="sex" id="sex" class="box" >
<option
All</option>
<option >Male</option>
<option >Female</option>
</
select>*<br class="clearBoth" /></td>
</tr>
<tr>
<td><label>District:</label></td>
<td><select name="district" id="district"
class="box" >
<option >Dhaka</option>
<option >Bagerhat</option>";
<option >Bandarnban</option>";
</select>
*<br class="clearBoth" /></td>
</tr>
<tr>
<td><label> Age:</label></td>
<td> <select name="age1" id="age1"
class="box">
<option
18</option>
<option >19</option>
<option >20</option>
<option >21</option>
<option >22</option>
<option >23</option>
<option >24</option>
<option >25</option>
<option >26</option>
<option >27</option>
<option >28</option>
<option >29</option>
<option >30</option>
<option >31</option>
<option >32</option>
<option >33</option>
<option >34</option>
<option >35</option>
</select>*
To
<select
name="age2" id="age2" class="box">
<option
35</option>
<option >34</option>
<option >33</option>
<option >32</option>
<option >31</option>
<option >30</option>
<option >29</option>
<option >28</option>
<option >27</option>
<option >26</option>
<option >25</option>
<option >24</option>
<option >23</option>
<option >22</option>
<option >21</option>
<option >20</option>
<option >19</option>
<option >18</option>
</
select>*<br class="clearBoth" /></td>
</tr>
<tr>
<td colspan="2" align="center"><div><input
type="submit" name="submit" value="Search!" />
</div></td>
</tr>
</form>
</table>
</body>
</html>
Heare everything is working fine but Seaking does not
work properly. When I select Male or Female and press
submit It show all result, even male and female too.