fnServerData: unable to display data containing letter(s)
fnServerData: unable to display data containing letter(s)
swarabhaskara
Posts: 5Questions: 0Answers: 0
This is supposedly very easy but I've been unable to resolve it.
I am trying to use fnServerData :
[code]
"fnServerData" : function ( sSource, aoData, fnCallback ) {
// push parameter onto the aoData array.
aoData.push( { "name": "kd_skpd", "value": "12003B" } );
// send request to server, use default fnCallback to process returned JSON
$jx.ajax( {
"dataType": 'json',
"type": "GET",
"url": sSource,
"cache": false,
"data": aoData,
"success": fnCallback
} );
},
[/code]
and in the serverside_processing.php I added the following to the where clause:
[code]
if ( isset($_GET['kd_skpd']) && $_GET['kd_skpd'] != "" ) {
if ($sWhere) $sWhere .= " AND kd_skpd=".mysql_real_escape_string( $_GET['kd_skpd'] );
else $sWhere = " WHERE kd_skpd=".mysql_real_escape_string( $_GET['kd_skpd'] );
}
[/code]
The error I get is Unknown column '12003B' in 'where clause', but if I change the value, for example, to "12003", DataTables displays the data correctly, including kode_skpd = "12003B". And, if I change the value with a numeric value that is not available under the field kode_skpd, for example "99999", the DataTables popped up the expected "No Data Found" info.
So, the code basically only works for me if the value is numeric but it doesn't if the value is a text? Please help. Thank you in advance.
I am trying to use fnServerData :
[code]
"fnServerData" : function ( sSource, aoData, fnCallback ) {
// push parameter onto the aoData array.
aoData.push( { "name": "kd_skpd", "value": "12003B" } );
// send request to server, use default fnCallback to process returned JSON
$jx.ajax( {
"dataType": 'json',
"type": "GET",
"url": sSource,
"cache": false,
"data": aoData,
"success": fnCallback
} );
},
[/code]
and in the serverside_processing.php I added the following to the where clause:
[code]
if ( isset($_GET['kd_skpd']) && $_GET['kd_skpd'] != "" ) {
if ($sWhere) $sWhere .= " AND kd_skpd=".mysql_real_escape_string( $_GET['kd_skpd'] );
else $sWhere = " WHERE kd_skpd=".mysql_real_escape_string( $_GET['kd_skpd'] );
}
[/code]
The error I get is Unknown column '12003B' in 'where clause', but if I change the value, for example, to "12003", DataTables displays the data correctly, including kode_skpd = "12003B". And, if I change the value with a numeric value that is not available under the field kode_skpd, for example "99999", the DataTables popped up the expected "No Data Found" info.
So, the code basically only works for me if the value is numeric but it doesn't if the value is a text? Please help. Thank you in advance.
This discussion has been closed.
Replies
[code]
if ( isset($_GET['kd_skpd']) && $_GET['kd_skpd'] != "" ) {
if ($sWhere) $sWhere .= " AND kd_skpd='".mysql_real_escape_string( $_GET['kd_skpd'] )."' ";
else $sWhere = " WHERE kd_skpd='".mysql_real_escape_string( $_GET['kd_skpd'] ). "' ";
}
[/code]