Jump to content

Published or Draft


Aureole

Recommended Posts

I'm trying to make a Published/Draft feature for my News System. I'm not sure how to do it exactly but...

 

I will have a row in my news table for "published" it will either be true or false, if published = true then the news will show to anyone, if it = false then it will only show to admin. Currently I have 3 categories each which shows 5 results, I want to build it into that but have no idea how...I'll try explain what I mean.

 

In category 1 there are 5 news stories, they were all posted on the same day into the category "test", one at 1pm, then the others at 2pm, 3pm, 4pm and 5pm.

 

The one posted at 3pm is marked as published = false the rest are marked as published = true. Normal users would see 4 the admins would see all 5, but they need to still be in order regardless of whether they are published or not.

 

Now my query at the moment to show the news from a category looks exactly like this...

 

<?php
$query = "SELECT title, short, full, author, authorid, cat, id, published date_format(date, '%a %D %b %Y %H:%i') as prettydate FROM news WHERE cat ='test' ORDER BY id DESC LIMIT 5";
$result = @mysql_query($query) or die(mysql_error());
if (mysql_num_rows($result)>0) {
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
echo "<a href=\"http://www.veraci7y.net/news/read.php?id={$row['id']}\" target=\"_blank\" title=\"Read full story...\" class=\"newstitle\">{$row['title']}</a>
<p class=\"newsinfo\">Posted by <a href=\"http://www.veraci7y.net/forums/index.php?showuser={$row['authorid']}\" class=\"user\" title=\"View Member's Profile\">{$row['author']}</a> <span class=\"newsdate\">{$row['prettydate']}</span></p>
<p class=\"newscontent\">{$row['short']}</p><br />";
// echo "<br /><a class=\"user\" href=\"javascript:openComments('$url')\">Comments</a></p><br />";
}
} else {
echo "No news to display."; }
?>

 

Now if I had an array...

 

<?php
$canviewdrafts = array(1, 3, 5, 7);
?>

 

I realize I could use something like...

 

<?php
if (in_array($member['id'], $canviewdrafts)) {
?>

 

But I have no idea to build that into my query...

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.