<?php
// Define the number of results per page 
$comentarii = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM comments"));
$max_results = 9; 
// 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"); 
if(!$sql)
{ 
echo "Nu sunt comentarii.";
}
while($row = mysql_fetch_array($sql)){ 
// Build your formatted results here.
$id = $row['id'];
$uname = $row['uname'];
$file = $row['file'];
$date = $row['date'];

$date_formated = date('H:i:s d/m/Y', $date);
$comment = substr($row['comment'],0,75);
$filetogo = mysql_fetch_array(mysql_query("SELECT file FROM fisiere WHERE id='$file'"));  
$avatar = mysql_query(mysql_query("SELECT avatar FROM utilizatori WHERE id='$file'")); 

$getusersonline="SELECT id,nume,color,avatar from utilizatori where nume='$uname'"; //grab from sql users on in last 15 minutes
$getusersonline2=mysql_query($getusersonline) or die("Could not get users");
while($getusersonline3=mysql_fetch_array($getusersonline2))
{
echo "<tr>
<td><img src='http://extremshare.net/avatar/$avatar[0]' width='35' height='35' alt=''>
<a href='profile.php?id=$getusersonline3[id]'><font color=\"$getusersonline3[color]\"><small>$uname</font></small></a>
   </td>
     <td><small><small>  ". $comment. " <br/> " . $date_formated. " </small></small>
    <br><a href=\"file.php?id=$file\"><small>$filetogo[0]</small></a></td>
   </tr>";
}
}
?>