分享一款php中博客日曆實現代碼,裡面有一句是查詢數據庫的這個很簡單,只要你修改一下字段名與你數據庫相同就行了,實例代碼如下:
function calendarnew($starttime = 0) {
global $db, $tablepre, $timestamp, $site_timeoffset, $site_dateformat, $curtime;
$$curtime = gmdate($site_dateformat, $ starttime + $timeoffset * 3600);
$pendtime = $starttime - (gmdate('j. $timeoffset * 3600) % 86400 ;
$pstarttime = $pendtime - gmdate('t', $pendtime + $timeoffset * 3600 + gmdate('t', $pendtime + $ timeoffset * 3600 + 1) * 86400;
$nendtime = $nstarttime + gmdate('t', $nstarttime + skip, $dim) = explode(' -', gmdate('w-t', $pendtime + $timeoffset * 3600 + 1));
🎇 ); $query = $db->query("SELECT dateline FROM {$tablepre}vitaitems WHERE dateline BETWEENof$ ($blog = $db ->fetch_array($query)) { $day = gmdate('j', $blog['dateline'] + $timeoffset 3600)); ? $blogs[$day] = array('num' => 1, 'dateline' => $blog['dateline'] - $blog['dateline'] % 86400) : $blog$blog['dateline'] % 86400) : $blog$blog['dateline'] % 86400) : $blog$blogs[$day]['numnum ']++; } $cal = ''; for($row = 0; $row '; for($col = 0; $col $cur = * 7 + $col $dim ? ' ' : $cur; if(!isset($blogs[$cur $curtd.''; } else { $cal .= '
$cal .= ''; return $cal;
}