我在NOW()
的數據庫中插入日期,然後查詢結果。這是代碼。從現在開始只查詢一個月的月份()
function get_content($id = ''){
if($id != ''):
$id = mysql_real_escape_string($id);
$sql = "SELECT * FROM cms_content WHERE id = '$id'";
$return = '<p><a href="index.php">Back to Content</a></p>';
else:
$sql = "SELECT * FROM cms_content ORDER BY id DESC";
endif;
$res = mysql_query($sql) or die(mysql_error());
if(mysql_num_rows($res) != 0):
while($row = mysql_fetch_assoc($res)) {
echo '<h1><a href="index.php?id=' . $row['id'] . ' "> ' . $row['title'] . '</a></h1>';
echo '<p>' . stripslashes($row['body']) . '</p>';
**echo '<p>' . $row['date_posted'] . '</p>';**
}
else:
echo '<p> You broke it!, this post dosn\'t exsist!';
endif;
echo $return;
的
echo '<p>' . $row['date_posted'] . '</p>';
是我回聲的日期。當我從數據庫回顯這個數據時,我得到了2012-07-25 19:00:46,因爲這就是數據庫中的內容。我的問題是,我如何迴應這一天,然後迴應本月,然後回顧這一年。理想情況下,這些都是獨立的回聲,所以我可以分別進行設計。
謝謝!這工作完美! – lilfinn 2012-07-26 01:48:20