Hello to all,
I am developing an web application and i have some problems creating the advanced search on this aplication.
I have 4 select boxes and an submit button. All i want is to make search on database from those select boxes. So the user can select just one selct box, or he can select two, or he can select all of them i need to get those results, what ever the user select's i want thr search script to do that.
i have one solution on my mind but i dont think that's the best one.
Let say i will use if statements. For example:
if the first select box is selected query the database only with that variable, if the first and second select boxes are selected give me the query for both variables, and so one. But this way i will need to make a lot of query's because there are a lot of combination's. A least i will need to create 16 query's.
I hope someone knows what i am trying to do and will help me on this task.
regards
4 Select boxe's web search
Moderator: General Moderators
Re: 4 Select boxe's web search
Help please, just post here any example, sample or whatever
Re: 4 Select boxe's web search
i try this way but is not working good
Code: Select all
if (!($kategoria =="Selekto Kategorinë") ||($lloji == "Selekto Lloin") || ($vendi == "Selekto Vendin") || ($adresa == ""))
{
$q = mysql_query("SELECT * FROM `tbllajmerimi` WHERE KategoriaID = '$kategoria' LIMIT $set_limit, $limit");
}
elseif (($kategoria =="Selekto Kategorinë") || !($lloji == "Selekto Lloin") || ($vendi == "Selekto Vendin") || ($adresa == ""))
{
$q = mysql_query("SELECT * FROM `tbllajmerimi` WHERE lloiID = '$lloji' LIMIT $set_limit, $limit");
}
elseif (!($kategoria =="Selekto Kategorinë") || !($lloji == "Selekto Lloin") || ($vendi == "Selekto Vendin") || ($adresa == ""))
{
$q = mysql_query("SELECT * FROM `tbllajmerimi` WHERE KategoriaID = '$kategoria' AND lloiID = '$lloji' LIMIT $set_limit, $limit");
}
elseif (!($kategoria =="Selekto Kategorinë") || !($lloji == "Selekto Lloin") || !($vendi == "Selekto Vendin") || !($adresa == ""))
{
$q = mysql_query("SELECT * FROM `tbllajmerimi` WHERE KategoriaID = '$kategoria' AND lloiID = '$lloji' AND Vendi = '$vendi' AND adresaid = '$adresa' LIMIT $set_limit, $limit");
}- aceconcepts
- DevNet Resident
- Posts: 1424
- Joined: Mon Feb 06, 2006 11:26 am
- Location: London
Re: 4 Select boxe's web search
Your method seems like a pretty typical method.
It's always a bit of a headache when there are so many fields that COULD be used
It's always a bit of a headache when there are so many fields that COULD be used