2016-08-29 6 views
0

このコードは、現在ログインしているユーザの詳細が青で強調表示されたテーブルを作成します。これは、$_SESSION['email']を使用して現在ログインしているユーザーを識別します。PHP/CSS現在ログインしているユーザの詳細をハイライト表示

テーブル構成内では、要素はCSSクラスcurUserとして宣言されます。この.curUserは、現在ログインしているユーザーを識別し、色付け/強調表示するためにCSSファイルで使用されます。

問題は、現在のユーザーが選択された後に空白行/行が作成されることです。私はかなり問題が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; 
} 
+0

私は[OK]を、それは私が最初にコメントアウト、助け – SumanKalyan

答えて

0

あなたはCLOあります二回表の行を歌う:

   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>"); 
+0

あなたの他の条件は右の場所で終了していないと思います。印刷( "");空白行/行が消えてしまいます。残っている問題は、次の登録ユーザの名前が(強調表示された)ログインユーザと同じ行に表示されることです。テーブルは次のように表示されます::#\t名前\t第1週\t第2週\t第3週\t第4週\t第5週{登録ユーザー}登録ユーザー名は、ログインしたユーザーと同じ行に表示されます。 – Tony75

関連する問題