Jump to content

Recommended Posts

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

Thanks, I figured it out  :D  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!!!  :D

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.