title: Print out login user data to match login SESSION
body: <p>I'm very new to PHP and Mysql I'm writing shopping website for my assignment,</p>
  
  <p>I have my login, registration, and database up and running, and now I'm at the stage that needs to do my User profile page that is required to pull data out from database, </p>
  
  <p>firstly I have this code working as it will pull everything from my table,</p>
  
  <pre><code>  &lt;?php
        $sql = 'SELECT * from assignment2';
        $result = $conn-&gt;query($sql);
        $rows = $result-&gt;fetchAll(PDO::FETCH_ASSOC);
  
        if(count($result)) {
            echo '&lt;table&gt;&lt;tr&gt;';
            //Heading
            foreach ($rows[0] as $columnName =&gt; $value) {
                echo '&lt;th&gt;' . $columnName . '&lt;/th&gt;' ;
            }
            echo '&lt;/tr&gt;';
            foreach ($rows as $row) {
                echo '&lt;tr&gt;';
                foreach ($row as $value) {
                    echo '&lt;td&gt;' . $value . '&lt;/td&gt;';
                }
                echo '&lt;tr&gt;';
            }
            echo '&lt;/table&gt;';
          }
          ?&gt;
  </code></pre>
  
  <p>but my question is how to make it pull out only the one that matching the login SESSION</p>
  
  <p>Here is my SESSION code</p>
  
  <pre><code>&lt;?php
  
  session_start();
  
  require '../ppuyakul/php/db_conn.php';
  
  if( isset($_SESSION['user_id']) ){
  
      $records = $conn-&gt;prepare('SELECT id,username,password FROM assignment2 WHERE id = :id');
      $records-&gt;bindParam(':id', $_SESSION['user_id']);
      $records-&gt;execute();
      $results = $records-&gt;fetch(PDO::FETCH_ASSOC);
  
      $user = NULL;
  
      if( count($results) &gt; 0){
          $user = $results;
      }
  
  }
  ?&gt;
  </code></pre>
  
  <p>Thanks so much in advance, looking forward for some nice answer ^^"</p>