Click here to Skip to main content
15,890,282 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
i have 8 fields as

Gender: Bride Groom
Age : From To
Height: From To
Religion:
Marital Status:
City:
State:
Country:
Search button.

I want a search query for this which take value from these fields and search according.
like if anyone want a search with only two fields or 3 fields etc etc he and she can get result according.
I have used these code but yet not get the exact result.

PHP
Is Query 1 in correct format?
Query 1: 
$query_for_result=mysql_query("select * from matri_user_info where (gender='$gender') and if($agemin='' and $agemax='') then (age between 18 and 100 )else (age between $agemin and $agemax) and if($hmin='' and $hmax='')then (height between 0 and 7 else (height between $hmin and $hmax) and if(religion='')then (religion !='') else(religion='$religion') and if (marital_status='')then (marital_status !='')else (marital_status='$marital_status') and if((city ='') then (city !='') else (city ='$city') and if (state='')then (state !='')else (state='$state') and if(country='')then(country !='') else(country='$country');");


Query 1:
SELECT  *FROM    pages WHERE   MATCH(gender, age,height,religion,marital_status,city,state,country) AGAINST ('$gender','between $agemin and $agemax','between $hmin and $hmax','$religion','$marital_status','$city','$state','$country' IN BOOLEAN MODE)


Query 3:
$query_for_result=mysql_query("select * from matri_user_info where (gender='$gender') or (age between $agemin and $agemax) or (height between $hmin and $hmax) or (religion='$religion') or (marital_status='$marital_status') or (city ='$city') or (state='$state') or (country='$country');");


Query4:

$query_for_result=mysql_query("select * from matri_user_info where (gender='$gender') and (age between $agemin and $agemax) and (height between $hmin and $hmax) and (status='unlock');");


If anyone has the answer for this? Please Share with me, i am searching for this since long.

Thanks
Posted
Updated 3-Apr-13 19:50pm
v2

1 solution

For such scenarios you needs to implement dynamic query.
Check below link
http://flylib.com/books/en/1.142.1.57/1/[^]
 
Share this answer
 
Comments
[no name] 4-Apr-13 7:05am    
I think you didn't get me. Please refer any matrimonial website then try to understand what i want.
Thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900