Hi
I have table called urls and it contains fields: id, channel, datetime, nick, link. I have filter form in my page and it filters urls with given filters. My problem is that currently it supports one filter at same time. I wanted that i can use all 4 "filters" same time. So i can like select 2007-04-20 and nick Example. So it shows all nick examples links in that date.
I don't know how to do it good. My only thought of this is i do many many if-senteces.
if(!empty($filter_nick) and !empty($filter_datetime))
{
$query = mysql_query("SELECT * urls WHERE nick = '$filter_nick' AND datetime = '$filter_datetime'");
}
elseif.....
I have 4filters so i shoud do 4^4 = 256 if-senteces haha. So that isnt good way.
The problem is that i cant put all filters to query like this:
mysql_query("SELECT * urls WHERE nick = '$filter_nick' AND datetime = '$filter_datetime' AND channel = '$filted_channel' AND link = '$filter_link'");
if user manage to use only channel and link filters. then there is "where nick = '' AND datetime = ''" and it wont work.
I have table called urls and it contains fields: id, channel, datetime, nick, link. I have filter form in my page and it filters urls with given filters. My problem is that currently it supports one filter at same time. I wanted that i can use all 4 "filters" same time. So i can like select 2007-04-20 and nick Example. So it shows all nick examples links in that date.
I don't know how to do it good. My only thought of this is i do many many if-senteces.
if(!empty($filter_nick) and !empty($filter_datetime))
{
$query = mysql_query("SELECT * urls WHERE nick = '$filter_nick' AND datetime = '$filter_datetime'");
}
elseif.....
I have 4filters so i shoud do 4^4 = 256 if-senteces haha. So that isnt good way.
The problem is that i cant put all filters to query like this:
mysql_query("SELECT * urls WHERE nick = '$filter_nick' AND datetime = '$filter_datetime' AND channel = '$filted_channel' AND link = '$filter_link'");
if user manage to use only channel and link filters. then there is "where nick = '' AND datetime = ''" and it wont work.