I need help with jquery plugin DataTables server side processing and filtering.
I just can't figure out how to get the data that is displayed to be limited to only a specific post_id.
Currently when there's a request to view data, the user is linked to something like www.example-site.com/post?id=123 and the goal is to have DataTables only display the data for id=123.
I've only been able to set it up just pull everything from a particular table- I don't know how to tell datatables to just use the filter by the id.
Here is the html:
<script type="text/javascript" language="javascript" class="init">
$(document).ready(function() {
$('#research').DataTable( {
"processing": true,
"serverSide": true,
"ajax": "server_processing.php"
} );
} );
</script>
</head>
<body>
<table id="research" class="display" cellspacing="0" width="100%">
<thead>
<tr>
<th>Title</th>
<th>Link</th>
<th>Description</th>
<th>Type</th>
<th>Posted</th>
</tr>
</thead>
</table>
And here is the SQL:
<?php
$table = 'example_table';
$primaryKey = 'id';
$columns = array(
array( 'db' => 'title', 'dt' => 0 ),
array( 'db' => 'link', 'dt' => 1 ),
array( 'db' => 'description', 'dt' => 2 ),
array( 'db' => 'category', 'dt' => 3 ),
array(
'db' => 'post_date',
'dt' => 4,
'formatter' => function( $d, $row ) {
return date( 'M d, Y', strtotime($d));
}
)
);
$sql_details = array(
'user' => '*USER*',
'pass' => '*PW*',
'db' => 'example_database',
'host' => 'localhost'
);
require( 'ssp.class.php' );
echo json_encode(
SSP::simple( $_GET, $sql_details, $table, $primaryKey, $columns )
);
?>
I'm not a programmer by trade, but I can usually figure out what to do by searching around online. I'm at a total loss on this... any help would be much appreciated.