Page 1 of 1
multiple values
Posted: Sat Jul 06, 2002 5:13 am
by mrpaulfrank
im running a php script to search a mysql database. the table has a 'genre' column in it, and the php looks like this:
nothing big, but the problem im facing is this. some videos might pertain to a few different genres, and i want to somehow list all these genres in the 'genre' column and have the script search for the keyword in the value. after the if statement im running a loop that displays each result. does this all make sense?? ive tried inserting genres into the same 'genre' column separated by a space, comma...but then it wont find anything unless i search for exactly what the field says. anyone have any ideas on how to fix this one?
Posted: Sat Jul 06, 2002 5:31 am
by twigletmac
Once again, only because I'm feeling nice:
This
WON'T WORK - Every time it's run it will set $genre to 'comedy' no matter what $genre was before.
For the last time, to compare $genre to 'comedy' (or anything else for that matter)
Please note the double '=' instead of the single one.
Mac
Posted: Sat Jul 06, 2002 6:06 am
by mrpaulfrank
ive changed this, its still working just fine. is there any way i can do something like this:
Code: Select all
$query_Recordset1 = "SELECT id, title, genre, format, image FROM test WHERE $genre=='genre', $genre=='genre2'";
i know this isnt right, but what i want to do here is set up a few (maybe three) genre columns for secondary genres that the video might relate to, in the table. and i want the script to find the results that match from all different genre columns? does this make sense?
Posted: Sat Jul 06, 2002 11:10 am
by DSM
Code: Select all
query_Recordset1 = "SELECT id, title, genre, format, image FROM test WHERE $genre = 'genre' OR $genre = 'genre2'";
Posted: Sat Jul 06, 2002 4:24 pm
by mrpaulfrank
Radical, i thought it would be something as easy as that. works like a charm, thanks a lot!