Page 1 of 1

Pls Help

Posted: Mon Apr 30, 2007 10:26 am
by achintha
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.... :) :) :)

Code: Select all

<?php
// 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>

Posted: Mon Apr 30, 2007 10:36 am
by dhrosti
put "LIMIT 0, 5" at the end of the sql query. (i think... someone may correct me though)

thanks...

Posted: Mon Apr 30, 2007 10:53 am
by achintha
thanks...

Posted: Mon Apr 30, 2007 12:04 pm
by John Cartwright
[url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url] Section 1.1 wrote:2. Use descriptive subjects when you start a new thread. Vague titles such as "Help!", "Why?" are misleading and keep you from receiving an answer to your question.
Please make a better effort next time.

ok

Posted: Mon Apr 30, 2007 7:05 pm
by achintha
Sorry........