【发布时间】:2014-10-29 22:10:22
【问题描述】:
好的,我正在尝试使用 jQuery DataTable (DataTables.net) 从我的数据库中显示信息。 我可以让它正常显示整个表格的“笔记”,但我只想显示尚未阅读的笔记。所以我需要以某种方式包含一个 WHERE 子句,但我不清楚解决这个问题的最佳方法。
这是我目前显示整个表格的方式:
// DB table to use
$table = 'Notes';
// Table's primary key
$primaryKey = 'CID';
// 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' => 'CID', 'dt' => 0 ),
array(
'db' => 'CID',
'dt' => 0,
'formatter' => function( $d, $row ) {
return '<a href="profile.php?search='.$d.'" target="_Blank">'.$d."</a>";
}
),
array( 'db' => 'Title', 'dt' => 1 ),
array( 'db' => 'Name', 'dt' => 2 ),
array(
'db' => 'Date',
'dt' => 3,
'formatter' => function( $d, $row ) {
return date( 'jS M y', strtotime($d));
}
)
);
// SQL server connection information
$sql_details = array(
'user' => '*DB_USER*',
'pass' => '*Password*',
'db' => '*DatabaseName*',
'host' => 'localhost'
);
require( 'ssp.class.php' );
echo json_encode(
SSP::simple( $_GET, $sql_details, $table, $primaryKey, $columns )
);
我需要相当于SELECT * FROM Notes WHERE Status ='Unread'
【问题讨论】:
-
你读过这个链接吗? datatables.net/forums/discussion/20953/…。希望工作。
标签: php jquery mysql sql jquery-datatables