mahenda Posted April 13, 2021 Share Posted April 13, 2021 //please dont talk about sql injection, i'll work on it, the problem with this code, it count all entries in a database table but i wantto count only with nid = 1 $query = 'SELECT * FROM abc WHERE nid = if(!empty($_POST["search"]["value"])){ $query .= 'AND (a LIKE "%'.$_POST["search"]["value"].'%" OR b LIKE "%'.$_POST["search"]["value"].'%" OR c LIKE "%'.$_POST["search"]["value"].'%") '; } if(!empty($_POST["order"])){ $query .= 'ORDER BY '.$_POST['order']['0']['column'].' '.$_POST['order']['0']['dir'].' '; } else { $query .= 'ORDER BY id DESC '; } if($_POST["length"] != -1){ $query .= 'LIMIT ' . $_POST['start'] . ', ' . $_POST['length']; } $result = mysqli_query(dbConnect, $query); Quote Link to comment https://forums.phpfreaks.com/topic/312465-why-datatable-count-all-entries-look-at-this-codes/ Share on other sites More sharing options...
Barand Posted April 13, 2021 Share Posted April 13, 2021 First thing you should do is turn on error reporting and clear all your syntax errors. Then you can worry about getting the query right. Quote Link to comment https://forums.phpfreaks.com/topic/312465-why-datatable-count-all-entries-look-at-this-codes/#findComment-1585801 Share on other sites More sharing options...
mahenda Posted April 13, 2021 Author Share Posted April 13, 2021 23 minutes ago, Barand said: First thing you should do is turn on error reporting and clear all your syntax errors. Then you can worry about getting the query right. AWESOME SOLUTION THANKS, SOLVED, IT WAS A SYNTAX IN MY PHP SCRIPT, I CHECKED IN ERROR LOG Quote Link to comment https://forums.phpfreaks.com/topic/312465-why-datatable-count-all-entries-look-at-this-codes/#findComment-1585802 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.