|
Hi, guys. I'm currently learning php and have come across a little problem. I set up this while loop to display all the info in my table, which works fine. Now how can I change this so that it only displays the last 5 rows? rather than displaying everything.
Thanks for your help in advance.
Alex
$connection = mysql_connect($host,$user,$password)
or die ("couldn't connect to server");
$db = mysql_select_db($database,$connection)
or die ("couldn't select database");
$query = "SELECT * FROM ideas ORDER BY id";
$result = mysql_query($query)
or die ("couldn't execute query.");
while ( $row = mysql_fetch_array($result,MYSQL_ASSOC) )
{
echo "
<TR><TD bgcolor=999999><font face=verdana size=3><B>
<a href=ideas.php?idea={$row['id']}>{$row['title']}</a></b> -
<a href=more.php?topic={$row3['topicname']}>{$row3['topictext']}</a>
<TR><TD>
<font size=2>
<table><TR><TD valign=top>
<img src=./images/topics/{$row2['topicimage']} width=100 height=75><TD>
<font face=verdana size=2>{$row['toptext']}<BR><BR><center>
<font face=verdana size=2>
<a href=email.php?idea={$row['id']}><font color=999999>Email this to a friend</a> -
<a href=print.php?idea={$row['id']}><font color=999999>Printable version</a> -
<a href=comment.php?idea={$row['id']}><font color=999999>Comments</a> -
<a href=ideas.php?idea={$row['id']}><font color=999999>Read More</a>
</table><BR><BR>\n";
}
|