Forum Moderators: coopster
[edited by: eelixduppy at 4:32 am (utc) on Feb. 7, 2008]
[edit reason] no URLs, please [/edit]
$gettop5 = "Select TOP 5 from news order by id desc";
$gottop5 = mysql_query($gettop5);
Then, where you want to display it :
<?php
while ($val = mysql_fetch_array($gottop5))
{
$heading = $val["heading"];
$body = $val["body"];
etc...
?>
//YOUR TABLE TO DISPLAY IN HERE
<tr>
<td><?php echo $heading?></td>
etc...
</tr>
<?php }?>
This will loop through the whole resultset displaying one line of data at a time
Ex.
$user = "mysqlusername";
$pass = "mysqlpass";
$host = "mysqlhost";
$database = "mysqldb";
global $host, $user, $pass, $database, $username, $password;
$db_bks = mysql_pconnect($host,$user,$pass);
if (!$db_bks) {
echo "Login failed.";
exit;}
mysql_select_db($database);