title: How to get data for specific user, but from different table
body: <p>I want to display the data for user 1 from database A right after he logged in, right now the page showing all the data from the table.</p>
  
  <p>currently I have 2 table which is for <strong>user login</strong> and <strong>user transaction</strong>. so after they logged in, i want them to be able to view their own record. After do searching, im thinking that it has something to do with session. </p>
  
  <p>can someone help me? </p>
  
  <p><strong>connection.php</strong></p>
  
  <pre><code>&lt;?php
  $mysql_host = "localhost";
  $mysql_user = "root";
  $mysql_pass = "";
  $mysl_database = "mockup";
  
  $conn = mysql_connect($mysql_host, $mysql_user, $mysql_pass);
  mysql_select_db($mysl_database, $conn);
  ?&gt;
  </code></pre>
  
  <p><strong>login.php</strong></p>
  
  <pre><code>&lt;?php
  include("connection.php");
  
  if(isset($_POST["submit"])) {
  $username = $_POST["username"];
  $password = $_POST["password"];
  
  $sql = "SELECT * FROM user
          WHERE username='$username' AND password='$password'";
  $result = mysql_query($sql);
  $numRows = mysql_num_rows($result);
  if($numRows==1) {
      session_start();
      $_SESSION["ID"] = $ID;
      header("Location: ./profile_page.php");
  } else {
      echo "Invalid Login Information";   
  }
  }
  ?&gt;
  
  &lt;form action="&lt;?php echo $_SERVER['SCRIPT_NAME']; ?&gt;" method="post"&gt;
  &lt;table&gt;
  &lt;tr&gt;&lt;td&gt;User Name&lt;/td&gt;&lt;td&gt;&lt;input type="text" name="username" /&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;td&gt;Password&lt;/td&gt;&lt;td&gt;&lt;input type="password" name="password" /&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;input type="submit" name="submit" value="Login" /&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;/table&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p><strong>profile_page.php</strong></p>
  
  <pre><code>&lt;?php
  session_start(); // start the session
  include("connection.php");
  
  $ID = $_SESSION["ID"]; // store the user id into session
  
  $sql = "SELECT * FROM transaction WHERE ID='$ID'";
  $result = mysql_query($sql);
  
  if($row = mysql_fetch_array($result)) {
  $deposit = $row["deposit"];
  
  
  echo "
  &lt;table&gt;
      &lt;tr&gt;&lt;td&gt;transaction&lt;/td&gt;&lt;td&gt; : &lt;/td&gt;&lt;td&gt;$transaction&lt;/td&gt;&lt;/tr&gt;
  
  &lt;/table&gt;
  ";
  }
  ?&gt;
  </code></pre>