Editable Grid http://www.editablegrid.net/en/faqを使用してデータベースを編集可能にしています。すべてをダウンロードしてセットアップしましたが、複数の「日付」列を追加した場合にのみ完全に機能します日付は、デモ列がユーザーに表示する元の日/月 (文字で)/年の形式ではなく、標準の mysql 形式である 000-00-00 として返されます。私は PHP と jQuery の完全な初心者です。この問題を解決するためのアドバイスや洞察をいただければ幸いです。スクリプトの最後に、問題があると思われる行から not を追加しました。
/**
* This script loads data from the database and returns it to the js
*
*/
require_once('config.php');
require_once('EditableGrid.php');
/**
* fetch_pairs is a simple method that transforms a mysqli_result object in an array.
* It will be used to generate possible values for some columns.
*/
function fetch_pairs($mysqli,$query){
if (!($res = $mysqli->query($query)))return FALSE;
$rows = array();
while ($row = $res->fetch_assoc()) {
$first = true;
$key = $value = null;
foreach ($row as $val) {
if ($first) { $key = $val; $first = false; }
else { $value = $val; break; }
}
$rows[$key] = $value;
}
return $rows;
}
// Database connection
$mysqli = mysqli_init();
$mysqli->options(MYSQLI_OPT_CONNECT_TIMEOUT, 5);
$mysqli->real_connect($config['db_host'],$config['db_user'],$config['db_password'],$config['db_name']);
// create a new EditableGrid object
$grid = new EditableGrid();
/*
* Add columns. The first argument of addColumn is the name of the field in the databse.
* The second argument is the label that will be displayed in the header
*/
$grid->addColumn('id', 'ID', 'integer', NULL, false);
$grid->addColumn('freelance', 'Complete', 'boolean');
$grid->addColumn('name', 'Name', 'string');
$grid->addColumn('id_continent', 'Assigned To', 'string' , fetch_pairs($mysqli,'SELECT id, name FROM continent'),true);
$grid->addColumn('lastvisit', 'Assigned Date', 'date');
$grid->addColumn('cdate', 'CheckDate', 'date');
$grid->addColumn('ddate', 'DueDate', 'date');
/* The column id_country and id_continent will show a list of all available countries and continents. So, we select all rows from the tables */
//Ramon note that "NULL,false" here means that it cannot be edited so ponte trucha, cabron!!!!
$grid->addColumn('email', 'Email', 'html',NULL,false);
//I suspect it has to do with this line.Question poster comment.
$result = $mysqli->query('SELECT *, date_format(lastvisit, "%d/%m/%Y") as lastvisit FROM demo LIMIT 100');
$mysqli->close();
// send data to the browser
$grid->renderXML($result);