Hi friends, This is the member searching code which I use in my client's site www.bd5000.com It's have
Seaking:
District:
Age:
but it's only work on Seaking search function. If you see the form you will understand your self.
Please see the code and tell me what should fixing?
The code is::
<?php if(isset($_POST['sex'])) { $sex = $_POST['sex']; }elseif(isset($_GET['sex'])) { $sex = $_POST['sex']; } if(isset($_POST['district'])) { $district = $_POST['district']; }elseif(isset($_GET['district'])) { $district = $_POST['district']; } if(isset($_POST['age1'])) { $age1 = ($_POST['age1']); }elseif(isset($_GET['age1'])) { $age1 = ($_POST['age1']); } if(isset($_POST['age2'])) { $age2 = ($_POST['age2']); }elseif(isset($_GET['age2'])) { $age2 = ($_POST['age2']); } $perpage = 5; if(isset($_GET["page"])) { $page = intval($_GET["page"]); } else { $page = 1; } $calc = $perpage * $page; $start = $calc - $perpage; if ($sex == 'All') { $result = mysql_query("select * from member where (Sex = 'Male') || (Sex = 'Female') AND (Age BETWEEN '$age1' AND '$age2') || (District = '$district') Limit $start, $perpage"); } else if ($sex == 'Female') { $result = mysql_query("select * from member where (Sex = 'Female') AND (Age BETWEEN '$age1' AND '$age2') || (District = '$district') Limit $start, $perpage"); } else { $result = mysql_query("select * from member where (Sex = 'Male') AND (Age BETWEEN '$age1' AND '$age2') || (District = '$district') Limit $start, $perpage"); } $rows = mysql_num_rows($result); if($rows){ $i=0; ?> <?php while($row= mysql_fetch_array($result)) { //$row['Photo'] = "<img src="/user_image/ . $row['Photo']; ""/> if ($i%2) { $class = 'row1'; } else { $class = 'row2'; } $i += 1; $name=$row['FName']." ".$row['LName']; ?> <table width="100%"> <tr width="150" class="label"> <td width="173" rowspan="3"> <div align="center"> <?php if ($row['pd_image'] !='') { ?> <img src="image/product/<?php echo $row['pd_image']; ?>" width="120 height="118"/> <?php } else {?> <img src="image/no-image-small.png" width="120" height="118"/> <?php } ?> </div></td> <td height="21" colspan="2" > <div align="center" style="font:'Times New Roman', Times, serif; font-size:15px;"> <div align="left">Name: <?php if($name != '') { ?> <?php echo $name; ?> <?php }else { echo "N/A"; } ?> </div> </div></td> </tr> <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">Profession: <?php if($row['position'] != '') { ?> <?php echo $row['position']; ?> <?php }else { echo "N/A"; } ?> </div> </div></td> </tr> <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> <div align='right'><a href="detail.php?Id=<?php echo $row['ID'];?>"> View</a></div> </td> </tr> </table> <?php } ?> <?php } else { print "<p align='center'>Not find any user on you search. Please try again.</p>"; } ?> <table width="100%" cellspacing="2" cellpadding="2" align="center" > <tr> <td align="center"> <?php if(isset($page)) { if ($sex == 'All') { $result = mysql_query("select Count(*) As Total from member where (Sex = 'Male') || (Sex = 'Female') AND (Age BETWEEN '$age1' AND '$age2') || (District = '$district') "); $rows = mysql_num_rows($result); if($rows) { $rs = mysql_fetch_array($result); $total = $rs["Total"]; } $totalPages = ceil($total / $perpage); if($page <=1 ) { echo "<span id='page_links' style='font-weight:bold;'>Prev</span>"; } else { $j = $page - 1; echo "<span><a id='page_a_link' href='search.php?page=$j&sex=$sex&District=$district&Age=$age1&Age=$age2'>< Prev</a></span>"; } for($i=1; $i <= $totalPages; $i++) { if($i<>$page) { echo "<span><a href='search.php?page=$i&sex=$sex&District=$district&Age=$age1&Age=$age2' id='page_a_link'>$i</a></span>"; } else { echo "<span id='page_links' style='font-weight:bold;'>$i</span>"; } } if($page == $totalPages ) { echo "<span id='page_links' style='font-weight:bold;'>Next ></span>"; } else { $j = $page + 1; echo "<span><a href='search.php?page=$j&sex=$sex&District=$district&Age=$age1&Age=$age2' id='page_a_link'>Next</a></span>"; } } } else if ($sex == 'Female') { $result = mysql_query("select Count(*) As Total from member where (Sex = 'Female') AND (Age BETWEEN '$age1' AND '$age2') || (District = '$district') "); $rows = mysql_num_rows($result); if($rows) { $rs = mysql_fetch_array($result); $total = $rs["Total"]; } $totalPages = ceil($total / $perpage); if($page <=1 ) { echo "<span id='page_links' style='font-weight:bold;'>Prev</span>"; } else { $j = $page - 1; echo "<span><a id='page_a_link' href='search.php?page=$j&sex=$sex&District=$district&Age=$age1&Age=$age2'>< Prev</a></span>"; } for($i=1; $i <= $totalPages; $i++) { if($i<>$page) { echo "<span><a href='search.php?page=$i&sex=$sex&District=$district&Age=$age1&Age=$age2' id='page_a_link'>$i</a></span>"; } else { echo "<span id='page_links' style='font-weight:bold;'>$i</span>"; } } if($page == $totalPages ) { echo "<span id='page_links' style='font-weight:bold;'>Next ></span>"; } else { $j = $page + 1; echo "<span><a href='search.php?page=$j&sex=$sex&District=$district&Age=$age1&Age=$age2' id='page_a_link'>Next</a></span>"; } } else { $result = mysql_query("select Count(*) As Total from member where (Sex = 'Male') AND (Age BETWEEN '$age1' AND '$age2') || (District = '$district') "); $rows = mysql_num_rows($result); if($rows) { $rs = mysql_fetch_array($result); $total = $rs["Total"]; } $totalPages = ceil($total / $perpage); if($page <=1 ) { echo "<span id='page_links' style='font-weight:bold;'>Prev</span>"; } else { $j = $page - 1; echo "<span><a id='page_a_link' href='search.php?page=$j&sex=$sex&District=$district&Age=$age1&Age=$age2'>< Prev</a></span>"; } for($i=1; $i <= $totalPages; $i++) { if($i<>$page) { echo "<span><a href='search.php?page=$i&sex=$sex&District=$district&Age=$age1&Age=$age2' id='page_a_link'>$i</a></span>"; } else { echo "<span id='page_links' style='font-weight:bold;'>$i</span>"; } } if($page == $totalPages ) { echo "<span id='page_links' style='font-weight:bold;'>Next ></span>"; } else { $j = $page + 1; echo "<span><a href='search.php?page=$j&sex=$sex&District=$district&Age=$age1&Age=$age2' id='page_a_link'>Next</a></span>"; } } ?> <td> </tr> </table>