Good day all,
I'm having some challenges getting my search function to function properly.

I have the following set of code on the page I want to use to perform my search at the top. Part of the code is to do the search and another part is to paginate my result set. The pagination script works fine but the search parameters are giving me headache. The parameters are shown below:

Code:
<?php 

   //This does the actual searching
if (isset($_GET['action']) and $_GET['action'] == 'search')
{


//connect to the database
    if(include_once ('DatabaseManager.php')); 
	$conn = DatabaseManager::getConnection();
    //get the function
    include_once ('function.php');

    	$page = (int) (!isset($_GET["page"]) ? 1 : $_GET["page"]);
    	$limit = 1;
    	$startpoint = ($page * $limit) - $limit;
   	

if ($_GET['productName'] != '')
{
   $productName = trim($_GET['productName']);
}

if ($_GET['purchaseDateFrom'] != '')
{
   $purchaseDateFrom = trim($_GET['purchaseDateFrom']);
}

if ($_GET['purchaseDateTo'] != '')
{
   $purchaseDateTo = trim($_GET['purchaseDateTo']);
}

if ($_GET['productManufacturer'] != '')
{
   $productManufacturer = trim($_GET['productManufacturer']);
}

$values = array($productName, $purchaseDateFrom, $purchaseDateTo, $productManufacturer);

$condition = array('productName LIKE \'%'.$productName.'%\' ','productManufacturer LIKE \'%'.$productManufacturer.'%\' ',
'purchaseDate >=' . $productDateFrom AND 'purchaseDate <=' . $purchaseDateTo . ' ');

function not_null($val) {
return($val !="");
}

$filteredArr = array_filter($values,'not_null');
$fil_keys = array_keys($filteredArr);

$totFil = count($fil_keys);

for($i=0;$i<$totFil;$i++) {
$filter_key =$fil_keys[$i];
$result[] = $condition[$filter_key];

}

$condition_res = implode(' AND ',$result);

   		
$statement = "assets WHERE $condition_res";

 $query = $conn->query("SELECT * FROM {$statement} ORDER BY id DESC LIMIT {$startpoint} , {$limit}"); 
 $assetRegister = $conn->query("SELECT * FROM {$statement}"); 
 $asset = $assetRegister->rowCount(); 
}

require_once '../classes/Config.php'; 
$result = new ECConfig();
$result->getSiteName();
?>
If I search for product name based on the code pasted above, the code works fine and paginate my result, the only problem is that when I try to view page 2 of the paginated result, it comes up blank because I think the whole code is being run again since the page has the form and the code that handles the search. How do I overcome this?
Secondly, if I use product manufacturer, it displays the following:

Warning: implode() [function.implode]: Invalid arguments passed in C:\xampp\htdocs\asset\assetSearch.html.php on line 68

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ORDER BY id DESC LIMIT 0 , 1' at line 1' in C:\xampp\htdocs\asset\assetSearch.html.php:73 Stack trace: #0 C:\xampp\htdocs\asset\assetSearch.html.php(73): PDO->query('SELECT * FROM a...') #1 {main} thrown in C:\xampp\htdocs\asset\assetSearch.html.php on line 73

If I use the dates to search, it displays everything in the database and shows the following errors

Notice: Undefined variable: purchaseDateFrom in C:\xampp\htdocs\asset\assetSearch.html.php on line 48

Notice: Undefined variable: purchaseDateTo in C:\xampp\htdocs\asset\assetSearch.html.php on line 48

Notice: Undefined variable: productManufacturer in C:\xampp\htdocs\asset\assetSearch.html.php on line 48

Notice: Undefined variable: productManufacturer in C:\xampp\htdocs\asset\assetSearch.html.php on line 50

Notice: Undefined variable: productDateFrom in C:\xampp\htdocs\asset\assetSearch.html.php on line 51

Notice: Undefined variable: purchaseDateTo in C:\xampp\htdocs\asset\assetSearch.html.php on line 51

I believe there are errors with my syntax which I can't pick out. Please, how do I get this to work? Do I have the search form separate from the page to display the search result and if that is the case, how do I achieve that since header function and include won't help here. How do I get the code to work or is there a better approach to doing this? I saw the example I'm using on http://www.ajaxprojects.com/ajax/tut...php?itemid=806

Thanks is advance.