我得到一个未定义的索引:列和未定义的索引:在数据表中绘制错误

时间:2015-05-18 19:53:54

标签: php jquery datatable datatables

我在两个不同的项目上使用相同的服务器端代码。它在一个中工作,但在另一个中产生两个错误。这是php页面     

/*
 * DataTables example server-side processing script.
 *
 * Please note that this script is intentionally extremely simply to show how
 * server-side processing can be implemented, and probably shouldn't be used as
 * the basis for a large complex system. It is suitable for simple use cases as
 * for learning.
 *
 * See http://datatables.net/usage/server-side for full details on the server-
 * side processing requirements of DataTables.
 *
 * @license MIT - http://datatables.net/license_mit
 */

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Easy set variables
*/

// DB table to use
$table = 'salef';

// Table's primary key
$primaryKey = 'Parcel';


// Array of database columns which should be read and sent back to DataTables.
// The `db` parameter represents the column name in the database, while the `dt`
// parameter represents the DataTables column identifier. In this case simple
// indexes
$columns = array(
array( 'db' => 'Parcel',     'dt' => 'Parcel' ),
array( 'db' => 'StreetNumber',     'dt' => 'StreetNumber' ),
array( 'db' => 'StreetName',     'dt' => 'StreetName' ),
array( 'db' => 'StreetType',     'dt' => 'StreetType' ),
array( 'db' => 'StreetDirection',     'dt' => 'StreetDirection' ),
array( 'db' => 'school',     'dt' => 'school' ),
array( 'db' => 'twp',     'dt' => 'twp' ),
array( 'db' => 'corp',     'dt' => 'corp' ),
array( 'db' => 'SaleNumber',     'dt' => 'SaleNumber' ),
array( 'db' => 'SaleMonth',     'dt' => 'SaleMonth' ),
array( 'db' => 'SaleYear',     'dt' => 'SaleYear' ),
array( 'db' => 'SalePrice',     'dt' => 'SalePrice' ),
array( 'db' => 'LivingArea',     'dt' => 'LivingArea' ),
array( 'db' => 'Acres',     'dt' => 'Acres' ),
array( 'db' => 'YearBuilt',     'dt' => 'YearBuilt' ),
array( 'db' => 'Story',     'dt' => 'Story' ),
array( 'db' => 'Plus',     'dt' => 'Plus' ),
array( 'db' => 'Basement',     'dt' => 'Basement' ),
array( 'db' => 'Qtr',     'dt' => 'Qtr' ),
array( 'db' => 'Frame',     'dt' => 'Frame' ),
array( 'db' => 'Bedrooms',     'dt' => 'Bedrooms' ),
array( 'db' => 'BasementSqft',     'dt' => 'BasementSqft' ),
array( 'db' => 'FinishedBasment',     'dt' => 'FinishedBasment' ),
array( 'db' => 'AirCond',     'dt' => 'AirCond' ),
array( 'db' => 'GarageSqft',     'dt' => 'GarageSqft' ),
array( 'db' => 'GarageCode',     'dt' => 'GarageCode' ),
array( 'db' => 'AirCode',     'dt' => 'AirCode' ),
array( 'db' => 'Roof',     'dt' => 'Roof' ),
array( 'db' => 'RoofType',     'dt' => 'RoofType' ),
array( 'db' => 'Rooms',     'dt' => 'Rooms' ),
array( 'db' => 'FullBaths',     'dt' => 'FullBaths' ),
array( 'db' => 'HalfBaths',     'dt' => 'HalfBaths' ),
array( 'db' => 'Grade',     'dt' => 'Grade' ),
array( 'db' => 'MHRE',     'dt' => 'MHRE' ),
array( 'db' => 'NeighCode',     'dt' => 'NeighCode' ),
array( 'db' => 'PropClass',     'dt' => 'PropClass' ),
array( 'db' => 'LandValue',     'dt' => 'LandValue' ),
array( 'db' => 'BldgValue',     'dt' => 'BldgValue' ),
array( 'db' => 'parcelUrl',     'dt' => 'parcelUrl' ),
);

// SQL server connection information
$sql_details = array(
'user' => 'root',
'pass' => 'sql2002',
'db'   => 'mysql',
'host' => '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.
 */

require( '../js/DataTables-1.10.5/examples/server_side/scripts/ssp.class.php' );

echo json_encode(
SSP::simple( $_GET, $sql_details, $table, $primaryKey, $columns)
);
//echo '<pre>';
//echo print_r($_POST);
//
//echo print_r($sql_details);
//echo print_r($table);
//echo print_r($primaryKey);
//echo print_r($columns);
//
//echo '</pre>';

这都是在自己的php页面上,所以当我调用那个php页面时,我得到了这个,

Notice: Undefined index: columns in /www/websvr6/htdocs/re/js/DataTables-1.10.5/examples/server_side/scripts/ssp.class.php on line 177

Notice: Undefined index: draw in /www/websvr6/htdocs/re/js/DataTables-1.10.5/examples/server_side/scripts/ssp.class.php on line 263
{"draw":0,"recordsTotal":5342,"recordsFiltered":5342,"data":[{"Parcel":"010035000000","StreetNumber":"","StreetName":"STATE HWY 29","StreetType":"","StreetDirection":"","school":"2D","twp":"4A","corp":"","SaleNumber":" 364","SaleMonth":" 8","SaleYear":"06","SalePrice":" 128000","LivingArea":"","Acres":" 5600","YearBuilt":"","Story":"","Plus":"","Basement":"","Qtr":"","Frame":"","Bedrooms":"","BasementSqft":"","FinishedBasment":"","AirCond":"","GarageSqft":"","GarageCode":"","AirCode":"","Roof":"","RoofType":"","Rooms":"","FullBaths":"","HalfBaths":"","Grade":"","MHRE":"","NeighCode":" 102","PropClass":"501","LandValue":" 2030","BldgValue":"","parcelUrl":"http:\/\/www.co.wyandot.oh.us\/cards\/Curnt\/010035000000.pdf"},

大约有5k记录。我使用的是版本1.10.5。而且无法弄清楚这笔交易是什么。除了表名和列之外,这与我在另一页上所做的相同,但在此页面上它不起作用。如果我尝试使用ajax从主页调用此函数,我也会收到错误,这就是为什么我决定调用php页面来查看我得到的内容。我注意到的最重要的事情是,在输出中我得到了输出的开头

draw":0,"recordsTotal":5342,"recordsFiltered":5342,

在我的另一页上,我只是获取表数据。

0 个答案:

没有答案