title: PHP, Only select logged in username from database
body: <p>I basically want it to select only the current user thats logged in and then display there username and points instead it displays ALL users in the database</p>
  
  <p>This is the code that displays it</p>
  
  <pre><code>    &lt;?php
  include("connect.php"); // Includes the file connect.php to connect to database
  session_start(); // Starting session cookies
  if($_SESSION['LOGGEDIN'] == 1)  //Checking if they have the session cookie
  {
  
  
  $result = mysql_query("SELECT * FROM userdata");
  
  echo "&lt;table border='1'&gt;
  &lt;tr&gt;
  &lt;th&gt;Username&lt;/th&gt;
  &lt;th&gt;Points&lt;/th&gt;
  &lt;/tr&gt;";
  
  while($row = mysql_fetch_array($result))
    {
    echo "&lt;tr&gt;";
    echo "&lt;td&gt;" . $row['username'] . "&lt;/td&gt;";
    echo "&lt;td&gt;" . $row['points'] . "&lt;/td&gt;";
    echo "&lt;/tr&gt;";
    }
  echo "&lt;/table&gt;";
  
  mysql_close($con);
  }
  
  else
  {
      echo "&lt;title&gt;Error!&lt;/title&gt;";
      //Doesn't have session cookie
      echo "YOU ARE NOT LOGGED IN!";
  }
  ?&gt;
  </code></pre>