Pls Help with news script
I'm using news script for my site.I found this script.but when I put headline to home page the whole mysql result will be show as headline. but I want only latest 5 headlines.pls help me.... :)
<?php
<blockquote class=\"bb-quote-body\"><p class=\"bb-quote\">Quote:</p>
// load the configuration file.
include(\"config.php\");
//load all news from the database and then OREDER them by newsid
//you will notice that newlly added news will appeare first.
//also you can OREDER by (dtime) instaed of (news id)
$result = mysql_query(\"SELECT * FROM news ORDER BY newsid DESC\",$connect);
//lets make a loop and get all news from the database
while($myrow = mysql_fetch_array($result))
{//begin of loop
//now print the results:
echo \"<b>Title: \";
echo $myrow['title'];
echo \"</b><br>On: <i>\";
echo $myrow['dtime'];
echo \"</i><hr align=left width=160>\";
echo $myrow['text1'];
// Now print the options to (Read,Edit & Delete the news)
echo \"<br><a href=\\"read_more.php?newsid=$myrow[newsid]\\">Read More...</a>
|| <a href=\\"edit_news.php?newsid=$myrow[newsid]\\">Edit</a>
|| <a href=\\"delete_news.php?newsid=$myrow[newsid]\\">Delete</a><br><hr>\";
}//end of loop
<!-- here you have the right to go Home or Add News. It's HTML not PHP -->
<br><br>
<a href=index.php>Home</a> <a href=add_news.php>Add News</a></blockquote>
?>
kb posted this at 00:06 — 1st May 2007.
He has: 1,380 posts
Joined: Feb 2002
try
$result = mysql_query("SELECT * FROM news ORDER BY newsid LIMIT 5 DESC");
'ablaye posted this at 14:19 — 9th May 2007.
They have: 140 posts
Joined: Apr 2006
That would do it.
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.