Peterhead Dave Posted January 9, 2009 Share Posted January 9, 2009 Hi guys, I have a website which shows the last entry in the database as a "main" news article on the front page - ie headline, a picture and an introductory paragraph or two. Under this, the headlines for the next five articles are shown. This is currently run as two separate queries. It's been suggested that we may not want the newest article to be the main article, so I have added a new field, mainnews. This is a simple boolean field - 1 means it can be used as the main article, 0 means it can't. Two questions: 1. If I were continue to run this as two queries, would it be possible to exclude the result of query 1 $query = "SELECT news_id, headline, intro, author, date, date_format(date, '%W %e %M %Y') as formatted_date, lastupdate, picnumber, caption, body FROM news WHERE live = '1' AND mainnews='1' ORDER BY news_id DESC LIMIT 0,1"; from query 2 $query = "SELECT news_id, headline, author, date, date_format(date, '%W %e %M %Y') as formatted_date FROM news ORDER BY news_id DESC LIMIT 1,5"; Query 2 would continue to show older articles with mainnews='1', so it's not just a case of adding WHERE mainnews='0' to the query 2. Would it be possible to merge these into one query, and use php to determine which record populates the main article and which five only show the headlines? Many thanks for any help offered. Dave Link to comment https://forums.phpfreaks.com/topic/140213-displaying-news-items/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.