Where Statement Search Box Error

Where Statement Search Box Error

DanOshDanOsh Posts: 37Questions: 11Answers: 1

I created a new static function called reduced by copying the static function simple. So I can display all those boats reduced in price.

The display works great at http://www.skywateryachts.com/datatables/boats_reduced.html.

    static function reduced ( $request, $conn, $table, $primaryKey, $columns )
    {
        $bindings = array();
        $db = self::db( $conn );

        // Build the SQL query string from the request
        $limit = self::limit( $request, $columns );
        $order = self::order( $request, $columns );
        $where = self::filter( $request, $columns, $bindings );

        // Main query to actually get the data
        $data = self::sql_exec( $db, $bindings,
            "SELECT SQL_CALC_FOUND_ROWS `".implode("`, `", self::pluck($columns, 'db'))."`
             FROM `$table`
             $where WHERE Reduced = 'Reduced'
             $order
             $limit"
        );

        // Data set length after filtering
        $resFilterLength = self::sql_exec( $db,
            "SELECT FOUND_ROWS()"
        );
        $recordsFiltered = $resFilterLength[0][0];

However, when I try to use the Search box, I get syntax errors.

I discovered this forum post https://datatables.net/forums/discussion/20953/where-clause-using-ssp-class-php-solved and it seems it would work. But I don't know where the 'if' statement would go before the execution of SSP:sql_exec as the post stated.

Below is an example I suppose of my IF statement, but where in the above function I created?

if ( $where == '' ) { 
$where.=" where Reduced= Reduced "; /// if there's no where statement i add the where statement 
} else { 
$where.=" and Reduced= Reduced"; /// if where statement has something i only append the criteria
This discussion has been closed.