|
Hi i am trying to have a search box on my site where there is a different search variables such as man looking for woman in drop down boxes and country in a drop down box and state which is a text field for them to type in the name. The problem with it is, is that when i do a search it wont find any results unless there is the exact state which a user is in the database like say ontario as state
so run down i am searching
man
looking for woman both drop downs
country drop down box canada
state text box i put nothing
my results i get are no results found
but if i search doingthe same with state as ontario then the ontario results are displayed
in other words all fields must be filled in and must be exact i would like it so if they put nothing in the state field the canada people would still be found from the database but also if they do decide to put ontario as stae then the canada ontario results would be found specifically
Thanks for anyhelp in advanced
btw i am new to php so take it easy on me lol
$tabsearch=true;
$tabempty=false;
$tabdating=false;
$tabdatingpic=false;
if(isset($result)){
$end=+$search_result;
$start=$result*$end;
}
if($search){
if(!empty($pic)){
$sqlSearchPic=mysql_query("SELECT DISTINCT (i.userid) AS id, p.ptitle,i.imgstatus, p.adddate FROM datingwa_profile p, datingwa_userimage i
WHERE p.userid = i.userid AND p.psex = '$sex2' AND p.country = '$country' OR p.state LIKE '%*%' AND i.imgstatus = '2'
GROUP BY id ORDER BY p.adddate DESC ");
if(!empty($sqlSearchPic)){
$picnum=mysql_num_rows($sqlSearchPic);
if($picnum >=1){
$tabdatingpic=true;
}else if($picnum==0){
$tabempty=true;
}
}
}
else if(empty($pic)){
$sqlSearchAlle=mysql_query("SELECT * FROM datingwa_profile WHERE psex = '$sex2' AND pcountry = '$country' OR p.state LIKE '%*%' order by adddate desc");
if(!empty($sqlSearchAlle)){
$allenum=mysql_num_rows($sqlSearchAlle);
if($allenum >=1){
$tabdating=true;
}else if($allenum==0){
$tabempty=true;
}
}
}
}
?>
<html>
<head>
<title> search </title>
<?php include("metatag.php"); ?>
<link href="style.css" rel="stylesheet" type="text/css">
</head>
<body>
<table width="790" align="center">
<tr>
<th width="790" height="100" colspan="2" align="left" valign="top" scope="col"><?php include("head.php"); ?></th>
</tr>
<tr>
<th width="790" height="100" colspan="2" align="left" valign="top" scope="col"><table width="790" border="0" cellpadding="0" cellspacing="0" bordercolor="#000000">
<tr>
<th align="left" valign="top" scope="col"><table width="788" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="200" bgcolor="#B9D3EE"><?php include("tablogin.php"); ?></td>
<td width="590" bgcolor="#B9D3EE" align="center"><?php include("main_top.php"); ?></td>
</tr>
</table></th>
</tr>
</table></th>
</tr>
<tr>
<th width="200" height="500" align="left" valign="top" scope="col"><?php include("main_left.php"); ?></th>
<th width="580" align="center" valign="top" scope="col"><table width="570" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<th width="570" align="center" scope="col"><table width="350" border="1" cellpadding="0" cellspacing="0" bordercolor="#000000">
<tr>
<th width="350" bgcolor="#B9D3EE" scope="col"><?php print "$Search_MSG";?></th>
</tr>
<tr>
<th width="350" border="1" bordercolor="#ff0000" align="center" scope="col">
<table width="300" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="center">
<?php if($tabsearch){ ?>
<form action="<?php print "$PHP_SELF"; ?>" method="post">
<table width="350" border="0" cellspacing="5" cellpadding="0">
<tr>
<td width="350"><table width="350" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="150" align="right"><?php print "$Search_Iam_MSG";?></td>
<td width="200"><select name="sex1" >
<option value="<?php print "$Add_Pro_Male";?>"><?php print "$Search_Man_MSG";?>
<option value="<?php print"$Add_Pro_Female"; ?>"><?php print "$Search_Women_MSG"; ?>
</select></td>
</tr>
</table></td>
</tr>
<tr>
<td><table width="350" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="150" align="right"><?php print "$Search_search_MSG";?></td>
<td width="200"><select name="sex2" >
<option value="<?php print"$Add_Pro_Female"; ?>"><?php print"$Search_Women_MSG"; ?>
<option value="<?php print "$Add_Pro_Male";?>"><?php print "$Search_Man_MSG";?>
</select></td>
</tr>
</table></td>
</tr>
<tr>
<td><table width="350" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="150" align="right"><?php print "$Search_Country_MSG";?></td>
<td width="200" align="left"><select name="country">
<?php $Sql_country=mysql_query("select* from datingwa_country order by country asc ");
if(!empty($Sql_country)){
while($row_country=mysql_fetch_array($Sql_country) ){
$country_name=$row_country["country"];
$country_id=$row_country["countryid"];
?>
<option value="<?php print"$country_name" ?>"><?php print "$country_name";?></option>
<?php
}
}
?>
</select></td>
</tr>
</table></td>
</tr>
<td><table width="350" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="150" align="left"><?php print "$Search_State_MSG"; ?></td>
<td width="200" align="left"><input name="state" type="text" value="<?php print "$state" ?>" size="20" maxlength="39"></td>
</td>
</tr>
</table></td>
</tr>
<tr>
<td><table width="350" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="40" align="center"><input name="pic" type="checkbox" ></td>
<td width="310" align="left"><?php print "$Search_Showpic_MSG";?></td>
</tr>
</table></td>
</tr>
<tr>
<td align="center"><input name="search" type="submit" value="<?php echo"$Search_Submit_MSG";?>"></td>
</tr>
</table>
</form>
<?php } ?>
</td>
</tr>
<tr>
<td align="center"><?php if($tabempty){ ?>
<table width="350" border="0" cellspacing="0" cellpadding="0">
<tr>
<th width="375" scope="col"><?php print "$Search_Empty_MSG";?> </th>
</tr>
</table>
<?php } ?></td>
</tr>
</table>
</th>
</tr>
</table></th>
</tr>
<tr>
<td width="570" align="center"><?php if($tabdatingpic){ ?>
<table width="552" border="0" cellspacing="0" cellpadding="0">
<tr>
<th width="590" scope="col"><table width="550" border="1" cellpadding="0" cellspacing="0" bordercolor="#000000">
<tr>
<th width="550" align="left" bgcolor="#B9D3EE" scope="col"><table width="550" cellspacing="0" cellpadding="0">
<tr>
<th width="325" align="left" scope="col"><?php print "$Dating_Titel"; ?></th>
<th width="140" scope="col"><?php print "$Dating_Date"; ?></th>
<th width="85" scope="col"><?php print "$Dating_Pic"; ?></th>
</tr>
</table></th>
</tr>
<tr>
<td width="550" align="left" bordercolor="#FF0000"><table width="550" align="center" cellpadding="0" cellspacing="0">
<?php
if($picnum >=1){
while($rowprofil=mysql_fetch_array($sqlSearchPic)) {
$img_userid=$rowprofil["id"];
$profil_title=$rowprofil["ptitle"];
$profil_adddate=$rowprofil["adddate"];
$img_status=$rowprofil["imgstatus"];
if($img_status==2){
$pic=$Dating_Pic_yes;
}else{
$pic=$Dating_Pic_no;
}
?>
<tr>
<th width="325" align="left" scope="col"><a href="<?php print "dating.php?userid=$img_userid"?>" target="_blank"><?php print "$profil_title"; ?></a></th>
<th width="140" scope="col"><?php print "$profil_adddate"; ?></th>
<th width="85" scope="col"><?php print "$pic"; ?></th>
</tr>
<?php } } ?>
</table></td>
</tr>
</table></th>
</tr>
<tr>
<td align="center"> </td>
</tr>
</table>
<?php } ?></td>
</tr>
<tr>
<td width="570" align="center"><?php if($tabdating){ ?>
<table width="550" border="0" cellspacing="0" cellpadding="0">
<tr>
<th width="590" align="center" scope="col"><table width="550" border="1" cellpadding="0" cellspacing="0" bordercolor="#000000">
<tr>
<th width="550" align="left" bgcolor="#B9D3EE" scope="col"><table width="550" cellspacing="0" cellpadding="0">
<tr>
<th width="325" align="left" scope="col"><?php print "$Dating_Title"; ?></th>
<th width="140" scope="col"><?php print "$Dating_Date"; ?></th>
<th width="85" scope="col"><?php print "$Dating_Pic"; ?></th>
</tr>
</table></th>
</tr>
<tr>
<td width="550" bordercolor="#FF0000"><table width="550" align="center" cellpadding="0" cellspacing="0">
<?php
if($allenum >=1) {
while($rowprofil2=mysql_fetch_array($sqlSearchAlle )){
$profil_userid=$rowprofil2["userid"];
$profil_title=$rowprofil2["ptitle"];
$profil_adddate=$rowprofil2["adddate"];
$Sqlimage2=mysql_query("select* from datingwa_userimage where userid='$profil_userid' AND imgstatus='2' ");
if(!empty($Sqlimage2)){
$numimg=mysql_num_rows($Sqlimage2);
if($numimg==1){
$pic=$Dating_Pic_yes;
}else{
$pic=$Dating_Pic_no;
}
}
?>
<tr>
<th width="325" align="left" scope="col"><a href="<?php print "dating.php?userid=$profil_userid"?>" target="_blank"><?php print "$profil_title"; ?></a></th>
<th width="140" scope="col"><?php print "$profil_adddate"; ?></th>
<th width="85" scope="col"><?php print "$pic"; ?></th>
</tr>
<?php } } ?>
</table></td>
</tr>
</table></th>
</tr>
<tr>
<td align="center"> </td>
</tr>
</table>
<?php } ?></td>
</tr>
</table></th>
</tr>
<tr align="right" valign="top">
<th width="200" height="13" scope="col"> </th>
<th width="590" height="13" align="center" scope="col"><?php include("footer.php"); ?></th>
</tr>
</table>
</body>
</html>
|