i have a simple form with input fields, one for title $_GET['title']=$title, year $_GET['year']=$year, from_year $_GET['from_year']=$from_year, to_year $_GET['to_year']=$to_year.
i then wish to make a search.
$query="SELECT * FROM mydb WHERE title LIKE '%$title%' AND year '%$year%'"
works great!
it's when i try to add year range that messes things up.
how do i write my mysql_query with the year range?
edit. when year range is used $year will be blank and vice versa
$query="SELECT * FROM mydb WHERE title LIKE '%$title%' AND year '%$year%'" IS WRONG.
$query="SELECT * FROM mydb WHERE title LIKE '%$title%' AND year LIKE '%$year%'" is correct. thanks
about your reply thanks! and yes you're correct that is what i want
when $title isset, and $year, $from_year and $to_year is not. it works!
when $year isset, and $title, $from_year and $to_year is not. it works!
when $title and $year isset, and $from_year and $to_year is not. it works!
this is basically what my query does and what i have come so far.
now when i add your part to it. (theYear BETWEEN '%$year1%' AND '%$year2%')
when $title and $from_year and $to_year isset, and $year is not. it KINDA work! (because it returns $titles that are outside of $from_year and $to_year)
Bookmarks