Pass Paramters
Pass Paramters
xerk1
Posts: 6Questions: 5Answers: 1
When I change it $_GET['id'] to number work normally
if don't change it get this error https://datatables.net/manual/tech-notes/12
But it changes when I refresh page
Network Developer error IDK why no read this Get but work when I change id parameter from URL please help!
<br />
<b>Notice</b>: Undefined index: id in <b>C:\xampp\htdocs\School\admin\control\examples\php\users.php</b> on line <b>26</b><br />
{"data":[]}
Server script
<?php
/*
* Example PHP implementation used for the index.html example
*/
// DataTables PHP library
include( "../../php/DataTables.php" );
// Alias Editor classes so they are easy to use
use
DataTables\Editor,
DataTables\Editor\Field,
DataTables\Editor\Format,
DataTables\Editor\Mjoin,
DataTables\Editor\Options,
DataTables\Editor\Upload,
DataTables\Editor\Validate;
// Build our Editor instance and process the data coming from _POST
Editor::inst( $db, 'users', 'UID' )
->fields(
Field::inst( 'First_Name' )->validator( 'Validate::notEmpty' ),
Field::inst( 'Last_Name' )->validator( 'Validate::notEmpty' ),
Field::inst( 'Sitting_Number' )
)
->where( 'ClassID', $_GET['id'])
->process( $_POST )
->json();
JavaScript
<script type="text/javascript" language="javascript" class="init">
var editor; // use a global for the submit and return data rendering in the examples
$(document).ready(function() {
editor = new $.fn.dataTable.Editor( {
ajax: 'examples/php/users.php',
table: "#example",
fields: [ {
label: "First name:",
name: "First_Name"
}, {
label: "Last name:",
name: "Last_Name"
}, {
label: "Sitting Number:",
name: "Sitting_Number"
}
]
} );
var table = $('#example').DataTable( {
dom: "Bfrtip",
"ajax:"
{
url: "examples/php/users.php?id=<?php echo $_GET['id'] ?>"
},
columns: [
{
data: null,
defaultContent: '',
className: 'select-checkbox',
orderable: false
},
{ data: "First_Name" },
{ data: "Last_Name" },
{ data: "Sitting_Number" }
],
autoFill: {
columns: [ 3],
editor: editor
},
keys: {
columns: [ 3],
editor: editor,
},
select: {
style: 'os',
selector: 'td:first-child',
blurable: true
}
} );
} );
</script>
This discussion has been closed.