嘗試按日期排序,但始終在創建colum'date'時添加日期NOT NULL,它將回顯'0000-00-00'而不是日期。嘗試按日期時間排序我的列表,但失敗
然後我做閱讀文章
CREATE TABLE `driptone`.`announces` (
`announcements` text,
`updated_at` TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`created_at` DATETIME DEFAULT NULL,
PRIMARY KEY (created_at)
);
但現在當我提交後說,一些SQL更改
MySQL的問題:列數並不在行1匹配值計數
我做錯了什麼?
//error_reporting(0);
$announcements = $_POST['announcement'];
if (!empty($announcements)) {
if (strlen($announcements) > 10) {
$date = date("Y/m/d");
$sql="INSERT INTO announcements (message, date_time) VALUES ('$announcements,$date')";
if (!mysql_query($sql))
die('MySQL problem:'.mysql_error());
} else {
echo 'Need to be atleast 10 characters long';
}
} else {
echo 'Fields are empty';
}
$queryPerson = mysql_query("SELECT * FROM announces ORDER BY created_at DESC") or die(mysql_error());
while($row = mysql_fetch_assoc($queryPerson)) {
echo $row['announcements'] . ' ' . $row['created_at'] . '<br /><br /><br />';
}
謝謝!
http://wiki.hashphp.org/PDO_Tutorial_for_MySQL_Developers – Nick 2013-02-20 00:11:55