opentable("Atsitiktiniai filmai");
$result = dbquery(
"SELECT tn.*, tc.*, user_id, user_name FROM ".$db_prefix."news tn
LEFT JOIN ".$db_prefix."users tu ON tn.news_name=tu.user_id
LEFT JOIN ".$db_prefix."news_cats tc ON tn.news_cat=tc.news_cat_id
WHERE ".groupaccess('news_visibility')." AND (news_start='0'||news_start<=".time().") AND (news_end='0'||news_end>=".time().")
ORDER BY RAND() LIMIT 0,5"
);
echo"<table cellpadding='0' cellspacing='2'>
<tr>";
if (dbrows($result) != 0) {
while($data = dbarray($result)) {
$itemsubject = trimlink($data['news_subject'], 23);
$wynik = dbquery("SELECT SUM(rating_vote) FROM ".DB_RATINGS." WHERE rating_type='N' AND rating_item_id='".$data['news_id']."'");
$info2 = dbresult($wynik,0);
$num_rating = dbcount("(rating_vote)", DB_RATINGS, "rating_type='N' AND rating_item_id='".$data['news_id']."'");
$wyn_rating = ($num_rating ? $info2 / $num_rating : 0);
$tas = $data['news_breaks'] == "y" ? nl2br(stripslashes($data['news_news'])) : stripslashes($data['news_news']);
echo "
<td width='100'>
<strong>Žiūrėjo: ".$data['news_reads']."</strong>
<br />
<a href='/news.php?readmore=".$data['news_id']."'><img src='".IMAGES_N.$data['news_image']."' width='120' height='180' /></a>
<br />
<img src='".THEME."images/retitingai/".ceil($wyn_rating).".png' width='80' height='13' alt='".ceil($wyn_rating)."' style='vertical-align:middle;' title='".ceil($wyn_rating)."' />
<br />
<a href='/news.php?readmore=".$data['news_id']."'>Žiūrėti</a>
</td>";
}
} else {
echo "<center>".$locale['004']."</center>\n";
}
echo "</tr>
</table>";
closetable();