<?php
defined('_IN_JOHNCMS') or die('Error: restricted access');
$total=mysql_result(mysql_query('SELECT COUNT(*) FROM `dnevniki` WHERE `views` > "0" and `dnid` = "txt" ;'), 0);
echo '<div class="phdr"><a href="./">Kundaliklar</a> | Eng ko`p o`qilgan</div>';
if($total > 0)
{
   $res1 = mysql_query('SELECT * FROM `dnevniki` WHERE `views` > "0" and `dnid` = "txt" ORDER BY `views` DESC LIMIT '.$start.',5;');
   $i=1;
   while($res = mysql_fetch_array($res1))
   {
      echo ($i % 2) ? '<div class="list1">' : '<div class="list2">';
      echo '<b><a href="?act=view&amp;id='.$res['id'].'"><img src="img/dn.png" width="16" height="16" /> '.htmlentities($res['zag'], ENT_QUOTES, 'UTF-8').'</a></b><br />';
      echo htmlentities(mb_substr($res['text'], 0, 100), ENT_QUOTES, 'UTF-8').'...<br />';
      $cont = mysql_result(mysql_query("SELECT COUNT(*) FROM `dnevniki` WHERE `dnid` = 'com' AND `com_id` = '".$res['id']."'"), 0);
      echo '<a href="?act=com&amp;id='.$res['id'].'">Fikrlar</a> ('.$cont.')';
      echo '<div class="sub">Qo`shilgan: '.date("d.m.y / H:i", $res['vr']).' <br /> Ko`rilgan: '.$res['views'].'</div>';
      echo '</div>';
      $i++;
   }
   echo '<div class="phdr">Jami: <b>'.$total.'</b></div>';
   if ($total > 5)
     echo '<div class="topmenu">' . functions::display_pagination('./?act=topview&amp;id='.$id.'&amp;', $start, $total, 5) . '</div>';
}
else
{
  echo '<div class="menu">Ko`rilgan kundaliklar yo`q!</div>';  
  echo '<div class="phdr">&nbsp;</div>';  
}

echo '<a href="./"><img src="./img/folder.png" /> Kundaliklar</a>';
?>
