The following code displays news content that I have stored in a mysql database. Right now the code displays all the news entries in the database. What I want is to only display 2 entries, because on a part of my website I only ahve room for 2.
So where in this code do I specifiy, display only 2 results from the database.
Please please help with this....thx everyone..
<?
$sql2 = "SELECT *
From phl_news
ORDER BY to_order_by DESC
";
$result2 = @($sql2,$connection) or die("Couldn't execute query.");
$num2 = mysql_num_rows($result2);
$counter = 0;
If ($num2 > 0)
{
while ($row2 = mysql_fetch_array($result2))
{
$counter++;
$id = $row2['id'];
$title = $row2['title'];
$newsdate = $row2['newsdate'];
$content = $row2['content'];
$content = substr($content, 0, 25);
$content = nl2br($content);
$var = strtotime($newsdate);
$months = array("January","February","March", "April", "May", "June","July", "August", "September", "October", "November", "December");
$today = getdate($var);
$mon = $today['mon'];
$show_mon = $months[$mon-1];
$mday = $today['mday'];
$year = $today['year'];
$option_news .= "<table width=450><tr><td bgcolor=\"#FFFFFF\"><span class=\"reports2\"><B>$title</B> - $show_mon $mday, $year</span></td></tr><tr><td bgcolor=\"#FFFFFF\" valign=bottom><span class=\"reports\">$content ...
<A HREF=newsdetails.php?$id/">more</A></span></td></tr></table>";
if ($counter < $num2)
{
$option_news .= "<BR>";
}
}
}
else
{
$option_news = "<table><tr>
<td bgcolor=\"#FFFFFF\"><span class=\"reports\">No Current Entries in Database</span></td>
</tr></table>";
}
?>