title: Username displaying at the wrong place in a table
body: <p>The code creates a table in which the currently logged in user details are highlighted in blue. The selection of the currently logged user id done using the session variable <code>$_SESSION['email']</code>, highlighting is done by giving  the  tags a CSS class 'curUser'The problem is that the name of a registered user(not the currently logged in user) is displayed in the same row as the currently logged in user. I think the problem is in php/table creation code. </p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
      &lt;head&gt;
  
  
      &lt;/head&gt;
      &lt;body&gt;
          &lt;h1&gt;Selections&lt;/h1&gt;
          &lt;?php
          require 'configuration.php';
          require 'connectTodb.php';
          ?&gt;
  
  
          &lt;table  border="1"  id="parent" &gt;
  
              &lt;tr&gt;
                  &lt;th&gt;#&lt;/th&gt;
                  &lt;th&gt;Name&lt;/th&gt;
                  &lt;?php
                  for ($i = 1; $i &lt; 6; $i++) {
                      print("&lt;th&gt;Week " . $i . "&lt;/th&gt;");
                  }
                  ?&gt;
              &lt;/tr&gt;
  
              &lt;?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("&lt;tr&gt;");
                  $rowId++;
                  $name = $rows["name"];
                  if ($rows['email'] == $_SESSION['email']) {
                      print("&lt;td class=" . $curUser . " type='hidden'   value=" . $rows['email'] . "&gt;" . $rowId . "&lt;/td&gt;");
                      print("&lt;td class=" . $curUser . "&gt; " . $rows["name"] . "&lt;/td&gt;");
                      while ($rows != null &amp; $name == $rows['name']) {
                          print("&lt;td class=" . $curUser . "&gt; " . $rows["team"] . "&lt;/td&gt;");
                          $rows = mysqli_fetch_assoc($result);
                      }
                  } else {
                      print("&lt;td type='hidden'  value=" . $rows['email'] . "&gt;" . $rowId . "&lt;/td&gt;");
                  }
  
                  print("&lt;td&gt; " . $rows["name"] . "&lt;/td&gt;");
                  while ($rows != null &amp; $name == $rows['name']) {
                      print("&lt;td &gt; " . $rows["team"] . "&lt;/td&gt;");
                      $rows = mysqli_fetch_assoc($result);
                  }
                  print("&lt;/tr&gt;");
              }
              ?&gt;
  
  
  
  
          &lt;/table&gt;
  
          &lt;?php
          mysqli_close($connection);
          ?&gt;
  
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Can anyone pinpoint the problem or suggest a solution ?</p>