Click here to Skip to main content
15,916,452 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am building a personal movie database. I've scraped my info from imdb with my pictures, ratings, year, yada yada. But my filter needs some tweaking/help. I can only seem to filter one word in my genre column.

I want to be able to show all records that contain the word Action (i.e. %Action%).

Right now it's returning the records where the only word in the column is Action.

The way the mysql column is setup, it has data in it like "Action, Drama, Thriller" or "Comedy, Drama, Romance" or "Action, Adventure". Currently, my filter is skipping these genre records and returning the ones that have just "Action".

I was hoping to find a way to tweak my filters.php which fills up my drop down menu in my filter form. I've tried a bunch of basic tweaks to try and allow any record with the word Action, or any record with the word Drama to no avail:

"Action" => "%Action%",
"Action" => "*Action*",
etc.

Here is my filters.php page.

PHP
$genres = array(
"Action" => "Action",
"Adventure" => "Adventure",
"Animatin" => "Animatin",
"Biography" => "Biography",
"Comedy" => "Comedy",
"Crime" => "Crime",
"Documentary" => "Documentary",
"Drama" => "Drama",
"Family" => "Family",
"Fantasy" => "Fantasy",
"Fil-Noir" => "Fil-Noir",
"History" => "History",
"Horror" => "Horror",
"Music" => "Music",
"Musical" => "Musical",
"Mystery" => "Mystery",
"Romance" => "Romance",
"Sci-Fi" => "Sci-Fi",
"Sport" => "Sport",
"Thriller" => "Thriller",
"War" => "War",
"Western" => "Western");


Any help would be greatly appreciated as this is the last thing I need to do to complete the project.

Jerome
Posted
Updated 30-Jul-14 15:47pm
v2
Comments
Mohibur Rashid 30-Jul-14 23:52pm    
It would be better if you show us what you have tried, as you have already mentioned that you tried.
jump_ace 31-Jul-14 15:22pm    
Sure.

"Action" => "%'Action'%",
"Action" => "*'Action'*",
"Action" => *'Action'*,
"Action" => %'Action'%,

I even tried to add some php to the option value in the drop down menu instead of using the filters.php:

Mohibur Rashid 31-Jul-14 19:09pm    
If short tag is enabled you simply can use: <option value=''>
if you want multiple comparison the query would be simple
SELECT Genre FROM Movies WHERE Genre LIKE 'Action1' OR/AND Genre LIKE 'Action2'

if you want user to select multiple Genre in html, various trick is applicable. One example can be the filter www.codeproject.com offers to filter your interest.
but that would not be only solution.
jump_ace 1-Aug-14 10:37am    
I can't seem to figure it out. So I've decided to change some things and do a work-around.

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