我正在尝试让我的所有存档链接(2012 年 2 月、2012 年 3 月等)在下拉菜单中工作。我让它显示并链接到最近一个月,但它不会在下拉菜单中显示其他月份。这是我的下拉菜单代码:
<h3>Archives</h3>
<form name="form" id="form">
<select name="jumpMenu" id="jumpMenu" onChange="MM_jumpMenu('parent',this,0)">
<option value="#">-- Select Archive Date --</option>
<option value="archive.php?archive=<?php echo $row_getArchives['link']; ?>"><?php echo $row_getArchives['archive']; ?></option>
</select>
</form>
有什么方法可以动态显示剩下的几个月。
这是目前基本情况的屏幕截图
编辑:这是我用于记录集的代码(即从数据库中获取数据)
$maxRows_getArchives = 10;
$pageNum_getArchives = 0;
if (isset($_GET['pageNum_getArchives'])) {
$pageNum_getArchives = $_GET['pageNum_getArchives'];
}
$startRow_getArchives = $pageNum_getArchives * $maxRows_getArchives;
mysql_select_db($database_blog, $blog);
$query_getArchives = "SELECT DISTINCT DATE_FORMAT(news.updated, '%M %Y') AS archive, DATE_FORMAT(news.updated, '%Y-%m') AS link FROM news ORDER BY news.updated DESC";
$query_limit_getArchives = sprintf("%s LIMIT %d, %d", $query_getArchives, $startRow_getArchives, $maxRows_getArchives);
$getArchives = mysql_query($query_limit_getArchives, $blog) or die(mysql_error());
$row_getArchives = mysql_fetch_assoc($getArchives);
if (isset($_GET['totalRows_getArchives'])) {
$totalRows_getArchives = $_GET['totalRows_getArchives'];
} else {
$all_getArchives = mysql_query($query_getArchives);
$totalRows_getArchives = mysql_num_rows($all_getArchives);
}
$totalPages_getArchives = ceil($totalRows_getArchives/$maxRows_getArchives)-1;
mysql_select_db($database_blog, $blog);
$query_getRecent = "SELECT news.post_id, news.title FROM news ORDER BY news.post_id DESC LIMIT 10";
$getRecent = mysql_query($query_getRecent, $blog) or die(mysql_error());
$row_getRecent = mysql_fetch_assoc($getRecent);
$totalRows_getRecent = mysql_num_rows($getRecent);
$maxRows_getDisplay = 1;
$pageNum_getDisplay = 0;
if (isset($_GET['pageNum_getDisplay'])) {
$pageNum_getDisplay = $_GET['pageNum_getDisplay'];
}
$startRow_getDisplay = $pageNum_getDisplay * $maxRows_getDisplay;
mysql_select_db($database_blog, $blog);
$query_getDisplay = "SELECT news.post_id, news.title, DATE_FORMAT(news.updated, '%M %e, %Y') AS formatted FROM news ORDER BY news.updated DESC";
$query_limit_getDisplay = sprintf("%s LIMIT %d, %d", $query_getDisplay, $startRow_getDisplay, $maxRows_getDisplay);
$getDisplay = mysql_query($query_limit_getDisplay, $blog) or die(mysql_error());
$row_getDisplay = mysql_fetch_assoc($getDisplay);
if (isset($_GET['totalRows_getDisplay'])) {
$totalRows_getDisplay = $_GET['totalRows_getDisplay'];
} else {
$all_getDisplay = mysql_query($query_getDisplay);
$totalRows_getDisplay = mysql_num_rows($all_getDisplay);
}
$totalPages_getDisplay = ceil($totalRows_getDisplay/$maxRows_getDisplay)-1;
mysql_select_db($database_blog, $blog);
$query_getPosts = "SELECT post_id, title, updated FROM news ORDER BY updated DESC";
$getPosts = mysql_query($query_getPosts, $blog) or die(mysql_error());
$row_getPosts = mysql_fetch_assoc($getPosts);
$totalRows_getPosts = mysql_num_rows($getPosts);
$queryString_getDisplay = "";
if (!empty($_SERVER['QUERY_STRING'])) {
$params = explode("&", $_SERVER['QUERY_STRING']);
$newParams = array();
foreach ($params as $param) {
if (stristr($param, "pageNum_getDisplay") == false &&
stristr($param, "totalRows_getDisplay") == false) {
array_push($newParams, $param);
}
}
if (count($newParams) != 0) {
$queryString_getDisplay = "&" . htmlentities(implode("&", $newParams));
}
}
$queryString_getDisplay = sprintf("&totalRows_getDisplay=%d%s", $totalRows_getDisplay, $queryString_getDisplay);
$queryString_getArchives = "";
if (!empty($_SERVER['QUERY_STRING'])) {
$params = explode("&", $_SERVER['QUERY_STRING']);
$newParams = array();
foreach ($params as $param) {
if (stristr($param, "pageNum_getArchives") == false &&
stristr($param, "totalRows_getArchives") == false) {
array_push($newParams, $param);
}
}
if (count($newParams) != 0) {
$queryString_getArchives = "&" . htmlentities(implode("&", $newParams));
}
}
$queryString_getArchives = sprintf("&totalRows_getArchives=%d%s", $totalRows_getArchives, $queryString_getArchives);
$var1_getDisplay2 = "-1";
if (isset($_GET['archive'])) {
$var1_getDisplay2 = $_GET['archive'];
$query_getDisplay = sprintf("SELECT news.post_id, news.title, news.blog_entry, DATE_FORMAT(news.updated, '%%M %%e, %%Y'), news. AS formatted FROM news WHERE DATE_FORMAT(news.updated, '%%Y-%%m') = %s ORDER BY news.updated DESC", GetSQLValueString($var1_getDisplay2, "text"));
} elseif (isset($_GET['post_id'])) {
$var2_getDisplay3 = $_GET['post_id'];
$query_getDisplay = sprintf("SELECT news.post_id, news.title, news.blog_entry, DATE_FORMAT(news.updated, '%%M %%e, %%Y') AS formatted FROM news WHERE news.post_id = %s", GetSQLValueString($var2_getDisplay3, "int"));
} else {
$query_getDisplay = "SELECT news.post_id, news.title, news.blog_entry, DATE_FORMAT(news.updated, '%M %e, %Y') AS formatted FROM news ORDER BY news.updated DESC LIMIT ".$pageNum_getDisplay.", 5";
}
$getDisplay = mysql_query($query_getDisplay, $blog) or die(mysql_error());
$row_getDisplay = mysql_fetch_assoc($getDisplay);
$totalRows_getDisplay = mysql_num_rows($getDisplay);
?>