Use php to calculate level
wanfuwu
wanfuwu 2017-05-30 21:13:36
0
2
775

20170530161608_365.png

<?php
    $aaa = "67";
    $bbb = "98";
    $ccc = "43";
    ?>
<table class="auto-style1" style="width: 28%; height: 134px">
    <tr>
        <td class="auto-style2">姓名</td>
        <td class="auto-style2">成绩</td>
        <td class="auto-style2">等级</td>
    </tr>
    <tr>
        <td class="auto-style2">AAA</td>
        <td class="auto-style2"><?php
         echo $aaa;
 ?></td>
        <td class="auto-style2"></td>
    </tr>
    <tr>
        <td class="auto-style2">BBB</td>
        <td class="auto-style2"><?php
         echo $bbb;
 ?></td>
        <td class="auto-style2">&nbsp;</td>
    </tr>
    <tr>
        <td class="auto-style2">CCC</td>
        <td class="auto-style2"><?php
         echo $ccc;
 ?></td>
        <td class="auto-style2">&nbsp;</td>
    </tr>
</table>

How to achieve hierarchical cell ranking?


wanfuwu
wanfuwu

reply all(2)
Ty80
<?php
$list=array(
    array('name'=>'AAA','score'=>67,'dengji'=>0),
    array('name'=>'BBB','score'=>98,'dengji'=>0),
    array('name'=>'CCC','score'=>43,'dengji'=>0),
);
function cmp($a,$b){
    global $list;
    $a=$list[$a]['score'];
    $b=$list[$b]['score'];
    if($a>$b){
        return true;
    }
    return false;
}
uksort($list,'cmp');
$list=array_values($list);
echo '姓名|分数|名次<br>';
foreach($list as $k=>$row){
    echo $row['name'].'|'.$row['score'].'|'.($k+1);
}


  • reply Ranking displayed from high to low
    PHP中文网 author 2017-05-31 09:41:11
phpcn_u2725

Achievements are judged on a range basis

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template