Because datatables do not filter the data when searching
Because datatables do not filter the data when searching
fernarey18
Posts: 11Questions: 6Answers: 0
Because datatables do not filter the data when searching.
Please download the code and detect the error
Use WAMP SERVER
https://drive.google.com/file/d/0B6Io7u_4OHBTUm9JcHFBemtWX1k/view
This discussion has been closed.
Answers
Please explain your problem in more detail and explain what debugging you have done.
Preferably provide a link to test case showing the problem.
Can you download the code, mount the database and get datatables to filter when searching for a record?
puede descargar el codigo, montar la base de datos y lograr que datatables filtre al buscar un registro?
I'm afraid I won't be download and executing arbitrary code. Happy to take a look at a test case if you provide a link to one though.
Allan
Hello Allan, excuse me, I do not speak English, I'm from Argentina.
I have to get the data from more than one table. Please download the SQL file
https://drive.google.com/file/d/0B6Io7u_4OHBTSjFGSDdidEIwZjQ/view?usp=sharing
I can not make datatables filter the data with the finder
HTML
JS
SERVER_PROCESSING.PHP
```
<?php
$hostname = 'localhost';
$dbname = 'ap_formato';
$dbusername = 'root';
$dbpassword = '';
$connection = mysql_connect($hostname, $dbusername, $dbpassword);
if(!$connection) {
die("database connecction failed." . mysql_error());
}
$db_select = mysql_select_db($dbname, $connection);
if(!$db_select) {
die("database selection failed." . mysql_error());
}
$params = $columns = $totalRecords = $data = array();
$params = $_REQUEST;
$where = $sqlTot = $sqlRec = "";
$sql = "SELECT * FROM compras ";
$sqlTot .= $sql;
$sqlRec .= $sql;
$sqlRec .= " ORDER BY fecha_ingreso DESC LIMIT ".$params['start']." ,".$params['length'];
$queryTot = mysql_query($sqlTot, $connection) or die("database error:". mysql_error($conn));
$totalRecords = mysql_num_rows($queryTot);
$queryRecords = mysql_query($sqlRec, $connection);
while( $row = mysql_fetch_array($queryRecords) ) {
$tmp = array();
$sqlcli = "select * from clientes where idcliente = '$row[idcliente]'";
$rescli = mysql_query($sqlcli);
$tempc = mysql_fetch_array($rescli);
$nombre = ucwords($tempc['nombre'].' '.$tempc['apellido']);
$tmp[0] = $nombre;
$tn = ''; $tnc = ''; $tnp = ''; $t = ''; $tne = ''; $o = 1;
}
$json_data = array(
"draw" => intval( $params['draw'] ),
"recordsTotal" => intval( $totalRecords ),
"recordsFiltered" => intval($totalRecords),
"data" => $data
);
echo json_encode($json_data);
<?php > ``` ?>I don't see any code in your server-side script that will search based on the value submitted by the client-side.
Do you actually need server-side processing? Are you working with 50k or more records?
Allan
more than 15000. And the data that I should get are in multiple tables not in a single.
I know I have to use $ params ['search'] ['value'] but I do not know how to do it when the data in multiple tables
In this example all the data is in a single table
http://phpflow.com/php/datatable-pagination-sorting-and-search-server-side-phpmysql-using-ajax/
With 15k rows you might get away with client-side processing. It depends how long it takes the server to read all of those rows.
You are correct that you need to handle the search parameters submitted by DataTables. They would likely need to be inserted into your join query somewhere. I'm afraid I can't write that server-side script for you though.
Allan