Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 82808

Problems With WHERE Clause

$
0
0
Hi there everybody... I'm using Datatables to get data from server trough AJAX request and I'm having some serious issues with WHERE clause and hope you can help me:
a) The Ajax request to get the data, is sent with a "GET" variable, this is being used to Filter the JSON response.
b) The server-side php have the WHERE section configured to filter using the GET variable, and the response is filtered
The problem appears when i use the Search filter, and due to it's config:
$sql_where = "WHERE ID_X=".$_GET['X'];
if ($_GET['sSearch'] != "")
{
    $sql_where = "WHERE ";
    foreach ($columns as $column)
    {
        $sql_where .= $column . " LIKE '%" . mysql_real_escape_string( $_GET['sSearch'] ) . "%' OR ";
    }
    $sql_where = substr($sql_where, 0, -3);
}
It filters from the whole SQL's main query, how can i use the Quick Search to filter from the "already filtered" data?

Thanks a lot!

PS = I've tried to put something like
$sql_where = "WHERE ID_X=".$_GET['X'];
if ($_GET['sSearch'] != "")
{
    $sql_where = "WHERE ID_X=".$_GET['X']." AND";
. . . 
but nothing... Hope this is not a repost, I've search but nothing like this, I know is easy but I just can't see it! Thanks!

Viewing all articles
Browse latest Browse all 82808


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>