Здравствуйте, уважаемые друзья! Есть сайт со статистикой игроков хоккейной команды. В БД вносится их статистика: голы, пасы, штрафные минуты и т.д. Возникла необходимость разделить статистику на сезоны, а именно - включать в выборку даты с 1.11.2016 по 31.05.2017.
Привожу фрагмент кода станицы functions.php (CMS Joomla):
function stat_pl($sid, $tm, $fl) {
global $wpdb;
$query = "SELECT *, SUM(st.goal) AS bombordir, SUM(st.pas) AS asistent, SUM(st.goal+st.pas) AS gp ,SUM(st.wgoal) AS wins, SUM(st.bgoal) AS big, SUM(st.mgoal) AS small, SUM(st.pen) AS shtraf FROM "
. "stat AS st, game AS g, consist AS c, team AS tm, tourney AS tr, season AS sn WHERE "
. "st.gid = g.gid AND st.cid = c.cid AND c.tmid = tm.tmid AND tm.own = 1 AND tr.trid = sn.trid AND g.sid = sn.sid";
if($sid != 0) $query .= " AND sn.sid = ".$sid;
if($tm != 0) $query .= " AND tm.tmid = ".$tm;
$query .= " GROUP BY c.cid ORDER BY gp DESC LIMIT 10";
$res = $wpdb->get_results($query, ARRAY_A);
if($wpdb->num_rows > 0) {
?>
<div class="bheader">
<h3>Статистика игроков</h3>
</div>
<?php
// гол+пас
if($fl == 1) {
echo '<table class="stable"><tr><th>№</th><th align="left">Игрок</th><th width="7%">Г</th><th width="7%">П</th><th width="7%">О</th><th width="7%">ШМ</th><th width="7%">ГБ</th><th width="7%">ГМ</th></tr>';
$i = 0;
foreach ($res as $row) {
$ed = (($i+1)%2 == 0)? 'class="ed"' : '';
echo '<tr '.$ed.'><td align="center">'.$row['number'].'</td>';
$tmp = explode(' ', $row['cname']);
echo '<td>'.$tmp[0].' '.$tmp[1].'</td>';
echo '<td align="center">'.$row['bombordir'].'</td>';
echo '<td align="center">'.$row['asistent'].'</td>';
echo '<td align="center">'.$row['gp'].'</td>';
echo '<td align="center">'.$row['shtraf'].'</td>';
echo '<td align="center">'.$row['big'].'</td>';
echo '<td align="center">'.$row['small'].'</td></tr>';
$i++;
}
echo '</table><br><br>';
}