繁体   English   中英

PHP / CSS突出显示当前登录用户的详细信息

[英]PHP/CSS Highlight the details for the currently logged in user

该代码创建一个表,其中当前登录的用户详细信息以蓝色突出显示。 这是使用$_SESSION['email']标识当前登录的用户来完成的。

在表构造中,元素声明为css类curUser 在CSS文件中使用此.curUser标识当前登录的用户并为其着色/突出显示。

问题是选择了当前用户后会创建一个空行/行。 我相当确定问题出在php表创建代码。

有人可以看看这个问题并指出问题,因为它目前正在困扰我?

HTML:

</head>
<body>
    <h1>Selections</h1>
    <?php
    require 'configuration.php';
    require 'connectTodb.php';
    ?>


    <table  border="1" id="parent" >
        <tr>
            <th>#</th>
            <th>Name</th>
            <?php
            for ($i = 1; $i < 6; $i++) {
                print("<th>Week " . $i . "</th>");
            }
            ?>
        </tr>

        <?php
        $sql = "SELECT selections.week,selections.team,users.email,users.name,selections.outcome FROM users,selections WHERE users.email = selections.email ORDER BY name,week";
        $result = mysqli_query($connection, $sql);
        print mysql_error();
        if (!$result) {
            die('Could not query:' . mysql_error());
        }
        $rowId = 0;
        $rows = mysqli_fetch_assoc($result);

        while ($rows != null) {
            print("<tr>");
            $rowId++;
            $name = $rows["name"];
            if ($rows['email'] == $_SESSION['email']) {
                print("<td class=" . $curUser . " type='hidden'   value=" . $rows['email'] . ">" . $rowId . "</td>");
                print("<td class=" . $curUser . "> " . $rows["name"] . "</td>");
                while ($rows != null & $name == $rows['name']) {
                    print("<td class=" . $curUser . "> " . $rows["team"] . "</td>");
                    $rows = mysqli_fetch_assoc($result);
                }
                print("</tr>");
            } else {
                print("<td type='hidden'  value=" . $rows['email'] . ">" . $rowId . "</td>");
            }
            print("<td> " . $rows["name"] . "</td>");
            while ($rows != null & $name == $rows['name']) {
                print("<td > " . $rows["team"] . "</td>");
                $rows = mysqli_fetch_assoc($result);
            }
            print("</tr>");
        }
        ?>
    </table>

        <?php
        mysqli_close($connection);
        ?>

</body>

的CSS

.curUser, #rowId  {
  background-color: lightblue; 
}

您要关闭表行两次:

                while ($rows != null & $name == $rows['name']) {
                    print("<td class=" . $curUser . "> " . $rows["team"] . "</td>");
                    $rows = mysqli_fetch_assoc($result);
                }
                print("</tr>");

和这里:

            while ($rows != null & $name == $rows['name']) {
                print("<td > " . $rows["team"] . "</td>");
                $rows = mysqli_fetch_assoc($result);
            }
            print("</tr>");

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM