Display Only A Partial List From DB
Display Only A Partial List From DB
Exvitermini
Posts: 7Questions: 0Answers: 0
I have the datatable working but server_process.php lists everything in the database table. I want to display only a partial list from the database table. For example, how can I do the equivalent of SQL would be SELECT * FROM tblStuff WHERE member_id=2? I need to incorporate the "WHERE" part into the data retrieved from server_process.php. I am dealing with multiple users so other users should not be able to see data in the table that doesn't belong to them.
I figured out that if a user is to do a search in the table, server_processing.php adds the WHERE clause. I want to be able to add WHERE clause for the full data retrieved so other data that doesnt comply with WHERE clause is not returned.
Anyone have any idea how I can achieve this?
I figured out that if a user is to do a search in the table, server_processing.php adds the WHERE clause. I want to be able to add WHERE clause for the full data retrieved so other data that doesnt comply with WHERE clause is not returned.
Anyone have any idea how I can achieve this?
This discussion has been closed.
Replies
the preferred way to add params to the server_processing call is to push params onto aoData in fnServerData
[code]
/* POST data to server */
$(document).ready(function() {
$('#example').dataTable( {
"sAjaxSource": "data_source.php",
"fnServerData": function ( sSource, aoData, fnCallback ) {
/* Add some data to send to the source */
aoData.push( { "name": "member_id", "value": $_SESSION["member_id"] } );
$.ajax( {
"dataType": 'json',
"url": sSource,
"data": aoData,
"success": fnCallback
} );
}
} );
} );
[/code]
of course on the server side look for $_GET["member_id"] (or $_REQUEST["member_id"]) and amend the WHERE clause