Welcome Guest, Not a member yet? Register   Sign In
Multiple search criteria
#11

[eluser]ninjayan[/eluser]
[quote author="Pert" date="1371639553"]That should do it, no?[/quote]

That is based on my understanding. Any suggestion how can I make my code show all data when all criterias are empty? thanks in advance
#12

[eluser]Pert[/eluser]
SQL query looks ok to me. What kind of checks are you doing before running search function (the function that returns <b>return $query->result_array(); </b>)?
#13

[eluser]ninjayan[/eluser]
check if criterias are empty
#14

[eluser]Pert[/eluser]
You can check if post data is present at all, and then check which values to search by in the search function itself, as you already do right now.

Even with empty search criteria, the _POST array has number of items in it, just with empty string as a value, so you can do this to check if post data is present.

Code:
if ($_POST)
{
   // run search routines
}

If you get alot of POST data anyway, you can insert hidden form field and name it "search-query" for example, then change the code to

Code:
if (isset($_POST['search-query']))
{
   ...
}




Theme © iAndrew 2016 - Forum software by © MyBB