Mossman Posted January 3, 2008 Share Posted January 3, 2008 Hi, I need to produce a news feed on a website. I am going to create a table to store the individual news articles but I only want to show, say; the three most recent articles on the home page. Does anyone have any recommendations on how to go about it? I know it's probably quite a simple query for you guys but I'm a bit of a newb Quote Link to comment https://forums.phpfreaks.com/topic/84337-solved-sorry-basic-question/ Share on other sites More sharing options...
shocker-z Posted January 3, 2008 Share Posted January 3, 2008 somthing along this line... $query= "select * from news ORDER BY date ASC LIMIT 3"; $result=mysql_query($query); while ($row=mysql_fetch_array($result)) { echo $row['subject']; } Regards Liam Quote Link to comment https://forums.phpfreaks.com/topic/84337-solved-sorry-basic-question/#findComment-429540 Share on other sites More sharing options...
simcoweb Posted January 3, 2008 Share Posted January 3, 2008 In your mysql query use the ORDER BY to sort it by date and the LIMIT so it shows just the 3. Quote Link to comment https://forums.phpfreaks.com/topic/84337-solved-sorry-basic-question/#findComment-429541 Share on other sites More sharing options...
Mossman Posted January 3, 2008 Author Share Posted January 3, 2008 Excellent, cheers guys. I'll give it a go. Quote Link to comment https://forums.phpfreaks.com/topic/84337-solved-sorry-basic-question/#findComment-429551 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.