Va bene così sto provando a visualizzare le informazioni dal mio database usando jQuery DataTable (DataTables.net). Posso farlo funzionare bene visualizzando l'intera tabella 'note', ma mi piacerebbe solo visualizzare le note che non sono state lette. Quindi ho bisogno di includere una clausola WHERE in qualche modo, ma non sono chiaro sul modo migliore per farlo.Come utilizzare la clausola 'WHERE' utilizzando ssp.class.php DataTables
Ecco come mi momento si possono visualizzare l'intera tabella:
// 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)
);
avrei bisogno l'equivalente di SELECT * FROM Notes WHERE Status ='Unread'
Hai letto questo link? https://datatables.net/forums/discussion/20953/where-clause-using-ssp-class-php-solved. Speriamo che funzioni. –