Listing Data Rows - How To
Listing Data Rows - How To
I am using Version: 1.9.4 if that matters.
I think I am on the right track I just dont know where to go from here. I am pulling data out of a MySQL database and used the "DataTables server-side script for PHP and MySQL" example and when I visit that page it is outputing valid json, I checked. Both files are in root directory.
Here is the invocation script:
[code]
$(document).ready(function() {
$('#dyntab').dataTable( {
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "user_list_script.php"
} );
} );
[/code]
Then here is what I have in my html (Which is a .php page if that matters).
[code]
User List
id
user_id
fname
lname
[/code]
I am just not sure how to get the data that is output from the user_list_script.php to show up in the table. I am new to jquery this is actually my first go it and I am just so lost. Any help would be greatly appreciated. I ran a debug thing and the URL for that is http://debug.datatables.net/isuhel
I would link to the page but it is on internal network that requires a login.
I think I am on the right track I just dont know where to go from here. I am pulling data out of a MySQL database and used the "DataTables server-side script for PHP and MySQL" example and when I visit that page it is outputing valid json, I checked. Both files are in root directory.
Here is the invocation script:
[code]
$(document).ready(function() {
$('#dyntab').dataTable( {
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "user_list_script.php"
} );
} );
[/code]
Then here is what I have in my html (Which is a .php page if that matters).
[code]
User List
id
user_id
fname
lname
[/code]
I am just not sure how to get the data that is output from the user_list_script.php to show up in the table. I am new to jquery this is actually my first go it and I am just so lost. Any help would be greatly appreciated. I ran a debug thing and the URL for that is http://debug.datatables.net/isuhel
I would link to the page but it is on internal network that requires a login.
This discussion has been closed.
Replies
That backward slash doesn't belong.
Allan
The can be disregarded. I deleted it. I am going to post the two pages in a seperate post.
[code]
Accolades - User Listings | YOUR CITY Call Center
<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<![endif]-->
$(document).ready(function() {
$('#dyntab').dataTable( {
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "user_list_script.php" } );
} );
<!--[if lte IE 8]>
<![endif]-->
[/code]
[code]
Data Table
id
attuid
fname
lname
[/code]
[code]<?php
/*
* Script: DataTables server-side script for PHP and MySQL
* Copyright: 2010 - Allan Jardine
* License: GPL v2 or BSD (3-point)
*/
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Easy set variables
*/
/* Array of database columns which should be read and sent back to DataTables. Use a space where
* you want to insert a non-database field (for example a counter or static image)
*/
$aColumns = array( 'id', 'attuid', 'fname', 'lname');
/* Indexed column (used for fast and accurate table cardinality) */
$sIndexColumn = "id";
/* DB table to use */
$sTable = "tbl_listofusers";
/* Database connection information */
$gaSql['user'] = "USER";
$gaSql['password'] = "PASS";
$gaSql['db'] = "DB";
$gaSql['server'] = "localhost";
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* If you just want to use the basic configuration for DataTables with PHP server-side, there is
* no need to edit below this line
*/
/*
* MySQL connection
*/
$gaSql['link'] = mysql_pconnect( $gaSql['server'], $gaSql['user'], $gaSql['password'] ) or
die( 'Could not open connection to server' );
mysql_select_db( $gaSql['db'], $gaSql['link'] ) or
die( 'Could not select database '. $gaSql['db'] );
/*
* Paging
*/
$sLimit = "";
if ( isset( $_GET['iDisplayStart'] ) && $_GET['iDisplayLength'] != '-1' )
{
$sLimit = "LIMIT ".mysql_real_escape_string( $_GET['iDisplayStart'] ).", ".
mysql_real_escape_string( $_GET['iDisplayLength'] );
}
/*
* Ordering
*/
if ( isset( $_GET['iSortCol_0'] ) )
{
$sOrder = "ORDER BY ";
for ( $i=0 ; $i $iFilteredTotal,
"aaData" => array()
);
while ( $aRow = mysql_fetch_array( $rResult ) )
{
$row = array();
for ( $i=0 ; $i
[/code]
{"sEcho":0,"iTotalRecords":"353","iTotalDisplayRecords":"353","aaData":[["1","sr0000","Stephen","Ruff"],["2","ss0000","Sarah","Sol"],["3","sw0000","Stacy","White"], ["353","ls1138","Luke","Skywalker"]]}