我正在使用可編輯網格http://www.editablegrid.net/en/faq使我的數據庫editable.I下載一切,並設置它,它的工作原理只有當我添加多個「日期」列日期的格式回來爲000-00-00其中是標準的mysql格式,而不是演示列向用戶顯示的原始日/月(字母)/年格式。我是PHP和jQuery中最大的總noob。任何建議或洞察力來解決這個問題將不勝感激。我添加了一個不是從我懷疑是問題的行腳本的末尾。如何將多個「日期」列添加到可編輯網格並仍然正常工作?
/**
* 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);
請與評論的人? – NewHistoricForm 2013-05-03 23:47:29
請理解,我們無法在此提供對第三方腳本的支持。請聯繫您在此處使用的軟件的供應商以獲取支持選項。或者把問題歸結爲一個具體的編程問題,然後詢問它。 – hakre 2013-05-04 04:35:24
你可能會喜歡這個:http://www.codecademy.com/tracks/php - 讓我知道它是否對你有幫助。 – hakre 2013-05-04 06:10:34