DataSpy Posted June 12, 2011 Share Posted June 12, 2011 I'm using a drop down menu to get a value to search a mysql db. The problem comes in when they want to search for everything for example in categories, it would be: all categories, comedy, horror, ect... How do I use a WHERE clause to search for everything, I tried * but that doesn't work. Example of my WHERE clause: FROM movies ORDER BY movie_main_title WHERE $row[movie_catagory] = $_POST[movie_catagory]"; Any help would be greatly appreciated, thanks in advance!!! Link to comment https://forums.phpfreaks.com/topic/239151-help-with-where-clause/ Share on other sites More sharing options...
fugix Posted June 12, 2011 Share Posted June 12, 2011 If you want all genres, why would you use a where clause? Link to comment https://forums.phpfreaks.com/topic/239151-help-with-where-clause/#findComment-1228769 Share on other sites More sharing options...
jtm62 Posted June 13, 2011 Share Posted June 13, 2011 For starters your order by clause should not be before the where clause. Link to comment https://forums.phpfreaks.com/topic/239151-help-with-where-clause/#findComment-1228858 Share on other sites More sharing options...
DataSpy Posted June 13, 2011 Author Share Posted June 13, 2011 Thanks, I figured it out I used LIKE and then made the passed variable for all categories %% The query looks like this $query_search_movies = "SELECT movies.movie_main_title, movies.movie_foreign_title, movies.movie_year, movies.movie_catagory, movies.movie_language, movies.movie_country, movies.movie_discs, movies.movie_format, movies.movie_extention, movies.movie_link, notes.notes_id, notes.notes_notes FROM movies LEFT JOIN notes ON movies.movie_notes_id = notes.notes_id WHERE movies.movie_catagory LIKE '$_POST[movie_catagory]' ORDER BY movies.movie_main_title"; $result_search_movies = mysqli_query($con, $query_search_movies) or die(mysqli_error($con)); Thanks for the help!!! Link to comment https://forums.phpfreaks.com/topic/239151-help-with-where-clause/#findComment-1228864 Share on other sites More sharing options...
fugix Posted June 13, 2011 Share Posted June 13, 2011 Glad you found the solution. Please mark as solved bottom left hand of page Link to comment https://forums.phpfreaks.com/topic/239151-help-with-where-clause/#findComment-1228876 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.