Hi there, I'm new to SQL and have a bit of a quandry...
I have a website for ex-armed forces personnel, people can set up a "friend finder" in order to be emailed when someone matching their search criteria joins the database.
They have three fields they can use :
Joined the forces between x and y years
Name of the person
Places that the person served at
With each of these fields they can 'activate' that search, so if you selected Joined between 1980 and 1990, and didn't activate any of the other fields then you would be emailed when anyone joined the database who served within those years.
If you also activated the 'Name of the person' field, you would be emailed if they served within those years AND were called Joe Bloggs or whatever.
The query I have built so far is :
$query="SELECT * FROM friend_finder WHERE (((year_joined <= '$Year_joined' AND year_left >= '$Year_left') AND year_activated = 'checked') AND ((name like '%$First_Name%' or name like '%$Surname%') and name_activated = 'checked') AND ((served_at = '$posting1') and served_at_activated = 'checked'))";
The trouble with this is that I need to make it say :
Is year_activated checked? If yes then get all the results where year_joined <= Year_joined and year_left >= Year_left
Is name_activated checked also ? If yes go through all the year results and check if the names match
If name_activated is not checked then see if any of the postings match the year results...
I hope this question makes enough sense for someone to help me.
Anyone got any ideas ??
Thanks for any help you can give
cheers
JT I don't make mistakes, I'm merely beta-testing life.
I have a website for ex-armed forces personnel, people can set up a "friend finder" in order to be emailed when someone matching their search criteria joins the database.
They have three fields they can use :
Joined the forces between x and y years
Name of the person
Places that the person served at
With each of these fields they can 'activate' that search, so if you selected Joined between 1980 and 1990, and didn't activate any of the other fields then you would be emailed when anyone joined the database who served within those years.
If you also activated the 'Name of the person' field, you would be emailed if they served within those years AND were called Joe Bloggs or whatever.
The query I have built so far is :
$query="SELECT * FROM friend_finder WHERE (((year_joined <= '$Year_joined' AND year_left >= '$Year_left') AND year_activated = 'checked') AND ((name like '%$First_Name%' or name like '%$Surname%') and name_activated = 'checked') AND ((served_at = '$posting1') and served_at_activated = 'checked'))";
The trouble with this is that I need to make it say :
Is year_activated checked? If yes then get all the results where year_joined <= Year_joined and year_left >= Year_left
Is name_activated checked also ? If yes go through all the year results and check if the names match
If name_activated is not checked then see if any of the postings match the year results...
I hope this question makes enough sense for someone to help me.
Anyone got any ideas ??
Thanks for any help you can give
cheers
JT I don't make mistakes, I'm merely beta-testing life.