ill try again :/
im setting up a blog page,
i want it to show posts via, poster or catagory or month or year, or a combination.
but only if the $_GET is in the url. if not and they just go to blogs.php i want it to just show the 12 most recent posts. no i have the catagory working on its own and poster working on its own.
here is my code so far, after editing it out a bit
<?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 }; ?>
ben
1 Answer