生病再試一次:/
IM建立一個博客頁面,
我想讓它顯示通過,海報或產品類別或一個月或一年,或一個職位組合。 但只有當$ _GET在url中。如果不是,他們只是去blogs.php我希望它只顯示最近的12個職位。不,我有自己的工作和自己的海報工作。
這裏是我的代碼,到目前爲止,編輯出來後一點
<?php
$category = mysql_real_escape_string($_GET['Category']);
$Poster = mysql_real_escape_string($_GET['Poster']);
$Month = mysql_real_escape_string($_GET['Month']);
$Year = mysql_real_escape_string($_GET['Year']);
$sql = "SELECT * FROM blog, blog_poster, blog_category WHERE blog.category = '$category'
AND blog_poster.pid = blog.posterid
AND blog_category.ID = blog.category
OR posterid = '$Poster'
AND blog_poster.pid = blog.posterid
AND blog_category.ID = blog.category
ORDER BY timestamp DESC LIMIT 5";
$result = mysql_query($sql) or print ("Can't select entries from table.<br />" . $sql . "<br />" . mysql_error());
while($row = mysql_fetch_array($result)) {
$date = date("D M d Y", $row['timestamp']);
$title = stripslashes($row['title']);
$entry = stripslashes($row['entry']);
$id = $row['id'];
$entry =substr($entry, 0, 250);
?>
<div class="ribbon">
<div class="wrapAround"></div>
<div class="tab">
<span class="blogDate"><?php echo $date; ?></span>
<span class="blogPostInfo">Posted by <a href="#"><?php echo $row['name']; ?></a> <!--| <a href="#">0 Comments</a --></span>
</div>
</div>
<div class="blogPostSummary">
<h1><span><b><?php echo $title; ?></b></span></h1>
<div class="blogPostImage">
<a href='cs_blog/content.php?id=<?=$id?>'class="img">
<img src="../images/content/blogs/cs_blog/date/headers/blog-post-01.JPG" width="556" height="133" alt="blog post image" /></a>
</div>
<p>
<?php echo $entry.".. <br><a href='content.php?id=$id'>Read more...</a>"; ?>
</p>
<p></p>
</div>
<!-- End of Content -->
<?php }; ?>
本
'isset'有什麼問題? – Rikesh 2012-03-02 11:45:33
isset看起來像是這裏的正確方法 – 2012-03-02 11:46:19
很難理解你想要達到的目標。你試過什麼了?向我們展示您的代碼 - 我們可能會指出錯誤。 – 2012-03-02 11:46:35