Use server side with params from GET

Use server side with params from GET

jeanpaul2777jeanpaul2777 Posts: 5Questions: 0Answers: 0
edited July 2012 in General
Hi everyone,

Sorry for this simple question, but I am a bit lost how to achieve my goal.
I would like to know how I can load data from mysql via server_processing.php (same as the one in example) by using a variable from GET.
I have a big table (>50000 rows) with non-unique IDs in the first column. Based on the url, my aim is to load entries in datatable with IDs matching the GET variable. I have a feeling that maybe fnServerParam might be the right answer, but I dont really know how to proceed.
Thank you for your help

[code]

url is like http://localhost/entry.php?var=00000000028


<?php $entry=$_GET['var'];?>
...






$(document).ready(function() {
var oTable = $('#example').dataTable( {
"bJQueryUI": true,
"bStateSave": true,
"sPaginationType": "full_numbers",
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "php/server_processing.php",
"sDom": 'T<"clear"><"H"lfr>t<"F"ip>',
"oTableTools": {
"sSwfPath": "/datatable/extras/TableTools/media/swf/copy_csv_xls_pdf.swf"
},
...

[/code]

Replies

  • allanallan Posts: 63,542Questions: 1Answers: 10,476 Site admin
    So you want to add an extra parameter to what is being sent to the server? In which case, yes, fnServerParams can be used to do that: http://datatables.net/release-datatables/examples/server_side/custom_vars.html

    Allan
  • jeanpaul2777jeanpaul2777 Posts: 5Questions: 0Answers: 0
    Thank you for your help allan,
    I had the feeling I should proceed by using fnServerParams,
    but I dont know what to write in the "fnServerParams":

    eg: aoData.push( { "name": "ID", "value": "<?php $entry?>" } );

    Moreover, I dont understand how the server can interpret this new pair values in Params?
    Shall I add extra-code in server_processing.php to deal with it?

    Sorry this is probably a trivial question, I am noob at programming ^^
    Again thank you for your amazing work, it would be really useful for my collegues

    JP
  • allanallan Posts: 63,542Questions: 1Answers: 10,476 Site admin
    The line of code above looks to to add whatever $entry is tot he ID property. Is that what you want?

    > Shall I add extra-code in server_processing.php to deal with it?

    Yes :-). If you define extra parameters, then the server will either ignore them, or do something with them. If you want it to do something, you need to tell it what.

    Allan
This discussion has been closed.