function rankByType($type = '') { global $gBeginTime, $gEndTime; switch ($type) { case 'day': // 过去5个交易日的日排名 $tradeDays = lastFiveTradeDays(time()); for ($i = 0; $i < 5; $i++) { $beginDate = $tradeDays[$i]; $endDate = date('Y-m-d', strtotime('+1 day', strtotime($beginDate))); $beginDatetime = $beginDate . ' ' . $gBeginTime; $endDatetime = $endDate . ' ' . $gEndTime; $data = getRankSet($beginDatetime, $endDatetime); $suffix = $type . ($i + 1); writeRankCache($data, $suffix); } break; case 'week': // 过去4周的周排名 for ($i = 1; $i <= 4; $i++) { list($beginDate, $endDate) = lastTradeNWeek(time(), $i); $endDate = date('Y-m-d', strtotime('+1 day', strtotime($endDate))); $beginDatetime = $beginDate . ' ' . $gBeginTime; $endDatetime = $endDate . ' ' . $gEndTime; $data = getRankSet($beginDatetime, $endDatetime); $suffix = $type . $i; writeRankCache($data, $suffix); } break; case 'month': // 过去1个月的月排名 list($beginDate, $endDate) = lastMonth(time()); $endDate = date('Y-m-d', strtotime('+1 day', strtotime($endDate))); $beginDatetime = $beginDate . ' ' . $gBeginTime; $endDatetime = $endDate . ' ' . $gEndTime; $data = getRankSet($beginDatetime, $endDatetime); writeRankCache($data, $type); break; default: return; } }
echo '<td>' . $k . '</td>'; } if (($j + 1) % 7 == 0) { echo '</tr><tr>'; } $j++; $k++; } while ($j % 7 != 0) { echo '<td style="color:#FFFFFF">' . $jzz . '</td>'; $j++; } echo '</tr>'; echo '<tr>'; echo "<td><a href=?" . lastYear($year, $month) . ">" . '<<' . '</a></td>'; echo "<td><a href=?" . lastMonth($year, $month) . ">" . '<' . '</a></td>'; echo '<td colspan = 3 style = "text-align:center">'; echo '<form name = "myform" method = "GET">'; echo '<select name = year >'; for ($start_year = 1970; $start_year < 2039; $start_year++) { echo '<option value =' . $start_year . '>' . $start_year . '</option>'; } echo '</select>' . '年'; echo '<select name = month>'; for ($start_month = 1; $start_month <= 12; $start_month++) { echo '<option value = ' . $start_month . '>' . $start_month . '</option>'; } echo '</select>'; echo '月'; echo '<input type = "submit" name = "search" value = "查询">'; echo '</form>';