用户名显示在表中的错误位置

时间:2016-08-29 16:54:11

标签: php css

代码创建一个表,其中当前登录的用户详细信息以蓝色突出显示。使用会话变量$_SESSION['email']选择当前记录的用户ID,突出显示是通过为标签提供CSS类'curUser'来解决的问题是注册用户的名称(不是当前登录的用户)显示在与当前登录用户相同的行中。我认为问题出在php / table创建代码中。

<!DOCTYPE html>
<html>
    <head>


    </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);
                    }
                } 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>
</html>

任何人都可以查明问题或建议解决方案吗?

0 个答案:

没有答案