How can I search for keywords or text strings and not values complete with php and mysqli code?
I need to change the code in this fragment to be able to do open searches and not by values. This is the piece of code that I don’t know how to modify to search for text strings:
if( !empty($requestData['search']['value']) ) {
// if there is a search parameter
$sql = "SELECT id, ej1, ej2";
$sql.=" FROM ejemplo";
$sql.=" WHERE id LIKE '".$requestData['search']['value']."%' "; // $requestData['search']['value'] contains search parameter
$sql.=" OR ej1 LIKE '".$requestData['search']['value']."%' ";
$sql.=" OR ej2 LIKE '".$requestData['search']['value']."%' ";
$query=mysqli_query($con, $sql) or die("xx-xx-xx.php: get PO");
$totalFiltered = mysqli_num_rows($query); // when there is a search parameter then we have to modify total number filtered rows as per search result without limit in the query
$sql.=" ORDER BY ". $columns[$requestData['order'][0]['column']]." ".$requestData['order'][0]['dir']." LIMIT ".$requestData['start']." ,".$requestData['length']." "; // $requestData['order'][0]['column'] contains colmun index, $requestData['order'][0]['dir'] contains order such as asc/desc , $requestData['start'] contains start row number ,$requestData['length'] contains limit length.
$query=mysqli_query($conexion, $sql) or die("ajax-grid-data.php: get PO"); // again run query with limit
} else {
$sql = "SELECT id, ej1, ej2 ";
$sql.=" FROM ejemplo";
$sql.=" ORDER BY ". $columns[$requestData['order'][0]['column']]." ".$requestData['order'][0]['dir']." LIMIT ".$requestData['start']." ,".$requestData['length']." ";
$query=mysqli_query($conexion, $sql) or die("xx-xx-xx-xx.php: get PO");
}