Aureole Posted July 26, 2007 Share Posted July 26, 2007 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... Quote Link to comment Share on other sites More sharing options...
teng84 Posted July 26, 2007 Share Posted July 26, 2007 try its only the where clause i made hope you understand or you may ask if not 'select * from table where anything not in '.implode(',',$yourarray).'' Quote Link to comment Share on other sites More sharing options...
Aureole Posted July 26, 2007 Author Share Posted July 26, 2007 I don't understand the code...could you explain it a little better please. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.