| Новости | FAQ | Авторы | Документация | В действии | Библиотека |
| Инструменты | Полезные ссылки | Хостинги | Скачать | Примеры | Форум |
Sanja v.2 28.05.2003 11:47
если таблица называется forum, столбец с номером реплики в таблице - cid, имя автора - в author, то код может выглядеть так (качество кода посредственное, писал год назад, когда глупый был - кстати, не факт, что поумнел с тех пор)))):^connect[$SQL.cs]{
$stat[^table::sql{show table status}]
^stat.menu{^if($stat.Name eq "forum"){
<ul>
<li>Реплик в форуме: <b>$stat.Rows</b></li>
<li>Средняя длина одной реплики: <b>$stat.Avg_row_length</b> символов</li>
<li>Объём форума: <b>$stat.Data_length</b> байт<br><i>(А Шекспир, для сравнения, за всю жизнь написал<br>порядка восьми мегабайт чистого текста…^;)</i></li>
</ul>}
}
}
^connect[$SQL.cs]{
$totalcnt[^table::sql{select count(cid) as counter from forum}]
^if($totalcnt){
$totalcntv(0)
^totalcnt.menu{$totalcntv(^eval($totalcntv + $totalcnt.counter))}
}
}
^connect[$SQL.cs]{
$share[^table::sql{select count(cid) as counter from forum group by author order by counter desc limit 10}]
^if($share){
$cumulshare(0)
^share.menu{$cumulshare(^eval($cumulshare + $share.counter))}
$a($totalcntv)
$b($cumulshare)
<p>Из всех <b>$a</b> реплик в форуме первым 10 авторам в рейтинге принадлежат <nobr><b>$b</b> постингов (<b>^eval(($b/$a)*100)%</b>).</nobr></p>
}
}
^connect[$SQL.cs]{
$tpwriters[^table::sql{select author, count(cid) as counter, (count(cid) / 5) as width, (count(cid) * 100 / ^totalcount[forum]) as percents from forum group by author order by counter desc limit 25}]
^if($tpwriters){
<table border=0 cellspacing=1 cellpadding=1 width=80%>
<tr valign=top>
<td><b>Автор</b></td>
<td> ^;</td>
<td colspan=2><b>Число реплик</b></td>
</tr>
$i(1)
^tpwriters.menu{
<tr valign=top>
<td class=small noWrap><span class=small>${i}.</span>^i.inc[] <a href="/forum/byauthor.html?a=^taint[uri][$tpwriters.author]" class=small>$tpwriters.author</a></td>
<td class=small noWrap> ^;  ^;</td>
<td class=smallest noWrap>$tpwriters.counter</td> $width($tpwriters.width)
<td class=smallest valign=middle align=left noWrap><a href="/forum/byauthor.html?a=^taint[uri][$tpwriters.author]"><img src="/etc/img/p.gif" style="border: solid 1px black^;background:$def_logoback" height="11" width="^width.format[%.0u]" alt=""></a> ^;${tpwriters.percents}%</td>
</tr>}[
]
</table>
}{
Форум пуст!
}
} Пример в действии - http://forum.gfk.ru/forum/stat.html