在上一篇文章的帮助下,我可以在 url 中添加破折号,但是,一旦完成此任务,我就无法加载正确的页面。
部分php代码:
$query_getDisplay = sprintf("SELECT blog.title, blog.description, blog.keywords,
blog.blog_entry, DATE_FORMAT(blog.updated, '%%M %%e, %%Y') AS formatted,
blog.blogphoto FROM blog WHERE blog.category = 'videos'
AND DATE_FORMAT(blog.updated, '%%Y-%%m') = %s
ORDER BY blog.updated DESC", GetSQLValueString($var1_getDisplay2, "text"));
} elseif (isset($_GET['title'])) {
$var2_getDisplay3 = $_GET['title'];
$query_getDisplay = sprintf("SELECT blog.title,blog.description, blog.keywords,
blog.blog_entry, DATE_FORMAT(blog.updated, '%%M %%e, %%Y') AS formatted,
blog.blogphoto FROM blog WHERE blog.title = %s",
GetSQLValueString($var2_getDisplay3, "text"));
} else {
$query_getDisplay = "SELECT blog.title, blog.blog_entry, blog.description,
blog.keywords, DATE_FORMAT(blog.updated, '%M %e, %Y') AS formatted,
blog.blogphoto FROM blog WHERE blog.category = 'videos' ORDER BY blog.updated DESC
LIMIT 2";
}
$getDisplay = mysql_query($query_getDisplay, $check_mag) or die(mysql_error());
$row_getDisplay = mysql_fetch_assoc($getDisplay);
$totalRows_getDisplay = mysql_num_rows($getDisplay);
?>
URL 正常工作的代码如下所示
<div id="recent">
<h3>Recent Post</h3>
<ul>
<?php do { ?>
<li><a href="videos.php?title=<?php echo str_replace(' ',
'-',$row_getRecent['title']); ?>"
><?php echo $row_getRecent['title']; ?></a></li>
<?php } while ($row_getRecent = mysql_fetch_assoc($getRecent)); ?>
<li> <a></a></li>
</ul>
</div>