Beispiel #1
0
 /**
  * Function gets the search results from the database 
  *		
  * 
  * 
  * @return string
  */
 function searchProducts()
 {
     $title = $_GET['title'];
     $brand = $_GET['brand'];
     $frommsrp = $_GET['frommsrp'];
     $tomsrp = $_GET['tomsrp'];
     $fromprice = $_GET['fromprice'];
     $toprice = $_GET['toprice'];
     $view = $_GET['view'];
     $sql = 'SELECT distinct pt.title,pt.product_id,pt.brand, pt.price,pt.msrp FROM products_table as pt ';
     $condition = array();
     if ($view != 'all') {
         if ($title != '') {
             $condition[] = "  pt.title like '%" . $title . "%'";
         }
         if ($brand != '') {
             $condition[] = " pt.brand like  '%" . $brand . "%'";
         }
         if ($frommsrp != '' && $tomsrp != '') {
             $condition[] = "  pt.msrp between '" . $frommsrp . "' and  '" . $tomsrp . "'";
         }
         if ($frommsrp != '' && $tomsrp == '') {
             $condition[] = "  pt.msrp > '" . $frommsrp . "'";
         }
         if ($frommsrp == '' && $tomsrp != '') {
             $condition[] = "  pt.msrp < '" . $tomsrp . "'";
         }
         if ($fromprice != '' && $toprice != '') {
             $condition[] = "  pt.price between   '" . $fromprice . "' and  '" . $toprice . "'";
         }
         if ($fromprice != '' && $toprice == '') {
             $condition[] = "  pt.price >   '" . $fromprice . "'";
         }
         if ($fromprice == '' && $toprice != '') {
             $condition[] = "  pt.price <   '" . $fromprice . "'";
         }
         if (count($condition) > 1) {
             $sql .= ' where ' . implode(' and ', $condition);
         } elseif (count($condition) > 0) {
             $sql .= ' where  ' . implode('', $condition);
         }
     }
     $obj = new Bin_Query();
     if ($obj->executeQuery($sql)) {
         $output = Display_DProductEntry::searchProducts($obj->records, '1', $this->data['paging'], $this->data['prev'], $this->data['next'], 0);
     } else {
         $output = Display_DProductEntry::searchProducts($obj->records, '0', $this->data['paging'], $this->data['prev'], $this->data['next'], 0);
     }
     return $output;
 }