news system problem : antal news på forsiden
hvordan gør jeg så kun de 5 nyeste nyheder bliver vist i mit news system?SCRIPT:
<?php
// instantiate variables (edit as necessary)
$host = ($host) ? $host : "localhost";
$user = ($user) ? $user : "";
$pwd = ($pwd) ? $pwd : "";
$link = mysql_connect($host,$user,$pwd) or die("Could not connect to Host.");
$field = nl2br($field);
echo $field;
$db="";
$link = mysql_connect($host,$user,$pwd) or die("Could not connect to Host.");
if (! $link)
die("kunne ikke oprette forbindelse til MySQL");
mysql_select_db($db , $link)
or die("kunne ikke åbne $db: ".mysql_error());
$result = mysql_query( "SELECT * FROM news ORDER BY newstime DESC" )
or die("SQL FEJL: ".mysql_error());
$num_rows = mysql_num_rows($result);
print "<table border=0 cellspacing=0 bordercolor=#000000>\n";
while ($get_info = mysql_fetch_row($result)){
print "<tr>\n";
foreach ($get_info as $field) ?>
<?php
$smilies=array(
":)" => "<img src='smilies/happy.gif' border=0>",
":(" => "<img src='smilies/sad.gif' border=0>",
":D" => "<img src='smilies/biggrin.gif' border=0>",
":P" => "<img src='smilies/tongue.gif' border=0>",
":p" => "<img src='smilies/tongue.gif' border=0>",
";)" => "<img src='smilies/wink.gif' border=0>",
";D" => "<img src='smilies/biggrin.gif' border=0>",
);
$field = str_replace(array_keys($smilies),array_values($smilies),$field);?>
<td valign="top" align="center"><font face="Verdana" size="1"/><?$field = nl2br($field); echo $field;?><hr width="510" noshade size="1" color="#000000"></font></td>
<?
print "</tr>\n";
}
print "</table>\n";
mysql_close($link);
?>