对不起标题不好,我的英语很差。
<select class="chosen2" name="mac" onchange="this.form.submit()">
<option></option>
<?php
error_reporting(0);
$maclist = mysql_query("SELECT year,split,leagueid,takim,versus,mac,week,day
FROM league WHERE id >= 0 $ligsarry $yearsarrf $splitsarrf GROUP by mac ORDER BY hafta desc,gun desc,mac desc,side asc, id asc");
while ($macs=mysql_fetch_array($maclist)) {
?>
<option <?php if (isset($_GET['mac']) && $_GET['mac']==$macs['mac']) {echo "selected='selected'"; } ?> value="<?php echo $macs['mac']; ?>"><?php echo $macs['mac'] . " -- W" . $macs['week'] . "D" . $macs['day'];;?></option>
<?php }?>
</select>我从下面的代码中得到了这个结果:

我想添加<optgroup label="Week 1 Day 2"> -w1d2 matches- </optgroup>
和<optgroup label="Week 1 Day 1"> -w1d1 matches- </optgroup>
但我不知道该怎么做。一天中的比赛计数并不总是4次。
发布于 2016-04-02 18:48:31
我认为这应该是可行的:
$current_day = 0;
while (...) {
if ($macs['day'] != $current_day) {
if ($current_day > 0) {
print '</optgroup>';
}
print '<optgroup>';
$current_day = $macs['day'];
}
print '<option>...</option>';
}
if ($current_day > 0) {
print '</optgroup>';
}每次你读新的$macs['day'],然后打印一个<optgroup>
https://stackoverflow.com/questions/36377321
复制相似问题