0

我希望你们都度过了一个美好的周末!

一段这样的代码 - 非常成功:

if($privs == "100") {

    // Lets set up our page display based on each 100 level users $id.
    $v = $_GET['v']; if ($_GET['v'] == "") $v = $id;
?>
  <table style="width: 100%; height: auto; margin: 0; border: 0;" cellspacing="0">
   <tbody><tr>
<?php
    // Get our list of all the active 100 level team members
    $team100 = mysqli_query($con, "SELECT * FROM staff_100 WHERE privs='100' AND active='yes'");
    $i = 0;
    while ($row100 = mysqli_fetch_assoc($team100)) {
        $i++;
        if ($i == $v) {
            $bg = $colour1;
            $bc = $colour1;
            $lnkc = " color: #ffffff;";
        } else {
            $bg = "transparent";
            $bc = "#c0c0c0";
            $lnkc = "";
        }
        echo "    <td style=\"background: " . $bg . "; border: 2px solid " . $bc . "; border-top-left-radius: 5px; border-top-right-radius: 5px; border-bottom: 0; text-align: center; padding: 2px 20px;\"><a href=\"./ops.php?v=" . $row100['id'] . "\" style=\"text-decoration: none;" . $lnkc . " display: block;\"><strong>" . $row100['forename'] . " " . $row100['surname'] . "</strong></a></td>\n";
    }
?>
   </tr></tbody>
  </table>

  <table style="width: 100%; height: auto; margin: 0; border: 2px solid <?=$colour1?>; border-top: 0; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px;" cellspacing="0">
   <tbody><tr style="background: <?=$colour1?>;">
    <td class="center" style="width: 10%;"><strong>Claim ID</strong></td>
    <td class="center" style="width: 20%;"><strong>Date received</strong></td>
    <td style="width: 40%;"><strong>Registrar name</strong></td>
    <td class="center" style="width: 13%;"><strong>Claim total</strong></td>
    <td class="center" style="width: 12%;"></td>
   </tr><?php
    // Get the regions and the ready_to_process claims in one db call.
    $result = mysqli_query($con, "SELECT * FROM registrar_claims WHERE reg_region IN (SELECT region FROM regions WHERE staff_100_id='$v') AND ready_to_process='yes' ORDER BY claim_id ASC");
    while ($row = mysqli_fetch_assoc($result)) {
        echo "\n   <tr style=\"background: " . cycleColours() . ";\">\n";
        echo "    <td class=\"center\">" . $row['claim_id'] . "</td>\n";
        echo "    <td class=\"center\">" . $row['timestamp_3'] . "</td>\n";
        echo "    <td>" . $row['reg_1st_name'] . " " . $row['reg_2nd_name'] . "</td>\n";
        echo "    <td class=\"center\">" . $row['exp_total'] . "</td>\n";
        echo "    <td class=\"center\"><a href=\"./ops.php?c=claimdisplay&amp;id=" . $row['reg_uri'] . "&amp;v=" . $_GET['v'] . "\">View</a></td>\n   </tr>";
    }
?>
</tbody>
  </table>
<?php
}
?>

只要我可以保证只有具有 privs 级别 100 的员工用户才会出现在“员工”表中,这真的很有效。我不再有这种保证 - 所有级别的所有用户现在都保存在一个普通员工表中,因此用户的“权限”可能是 100、200、300 或 400。

我对如何更改我的代码以使第一个表显示只有 100 个级别的员工感到有点迷茫,并且在它具有表排他性时完全按照以前的方式运行。我现在是否需要完全重构我的代码,还是我错过了一些简单且易于更改的东西?

谢谢!评论总是被阅读和欣赏。

4

0 回答 0