<?php
session_start();
?>
<?php
include("../stop.php");
include("header.php");
include("config.php");

echo "<br />Last 20 comments!<br />";

// Define the number of results per page 
$max_results = 20; 
// Figure out the limit for the query based 
// on the current page number. 
$from = (($max_results) - $max_results); 

$sql = mysql_query("SELECT * FROM comments ORDER BY id DESC LIMIT $max_results");
while($row = mysql_fetch_array($sql)){ 
$id = $row['id'];
$uname = $row['uname'];
$file = $row['file'];
$date = $row['date'];

$tofile = "<a href='file.php?id=$file'>more...<a/>";

$date_formated = date('H:i:s d-m-Y', $date);
$comment = substr($row['comment'],0,75)."&nbsp;". $tofile."";

$getusersonline = mysql_query("SELECT * FROM utilizatori WHERE nume='$uname'"); //grab from sql users on in last 15 minutes
while($getusersonline3=mysql_fetch_array($getusersonline))
{
$avat = $getusersonline3["setavatar"];
$id = $getusersonline3["id"];
$mod = $getusersonline3["color"];
$avatar = $getusersonline3["avatar"];
print "<tr>
<td>";

 if($avat[0]=="1")
	  {
		echo "<img src='../avatar/$avatar' alt='$uname' />";
	   }else{
		 echo "";
		}  
print "<small><a href='profile.php?id=$id' class='$mod'>$uname</a></small>
   </td>
<td><small> ". $comment. " <br/> " . $date_formated. " <br/></small></td>
   </tr>";

}}
include("flooter.php")
?>