title: i would like to ask about Mysql Select with multiple tables
body: <p>I have a table which is session, and has a session_id, another tables which are namespmember1, namespmember2, namespmember3</p>
  
  <p>Everytime i save the form which has the session table, namespmember1, namespmember2, namespmember3. They are all save also. which there ID's are equal becuase they are save as batch. </p>
  
  <p>my question is. i want to edit those tables or view... heres my code which is redundant and i guess there is a solution for it. </p>
  
  <p>Im getting the ID for the session table. </p>
  
  <pre><code>$id = $_GET['id'];
  $id = mysql_real_escape_string($id);
  $q = mysql_query("SELECT * FROM session WHERE session_id='$id'");
  $row = mysql_fetch_object($q);
  </code></pre>
  
  <p>And now i will display the tables namespmember1, namespmember2, namespmember3 </p>
  
  <pre><code>&lt;?php
  $sql = mysql_query("SELECT * FROM namespmember1 WHERE hon1_id='$id'");
  while ($row = mysql_fetch_object($sql))
  {
      echo "&lt;tr&gt;";
      echo "&lt;td&gt;$row-&gt;spmember_name&lt;/td&gt;";
      echo "&lt;td&gt;$row-&gt;present&lt;/td&gt;";
      echo "&lt;td&gt;$row-&gt;absent&lt;/td&gt;";
      echo "&lt;td&gt;$row-&gt;leave_sick&lt;/td&gt;";
      echo "&lt;td&gt;$row-&gt;business&lt;/td&gt;";
      echo "&lt;/tr&gt;";
  }
  $sql = mysql_query("SELECT * FROM namespmember2 WHERE hon2_id='$id'");
  while ($row = mysql_fetch_object($sql))
  {
      echo "&lt;tr&gt;";
      echo "&lt;td&gt;$row-&gt;spmember_name&lt;/td&gt;";
      echo "&lt;td&gt;$row-&gt;present&lt;/td&gt;";
      echo "&lt;td&gt;$row-&gt;absent&lt;/td&gt;";
      echo "&lt;td&gt;$row-&gt;leave_sick&lt;/td&gt;";
      echo "&lt;td&gt;$row-&gt;business&lt;/td&gt;";
      echo "&lt;/tr&gt;";
  }
  $sql = mysql_query("SELECT * FROM namespmember3 WHERE hon3_id='$id'");
  while ($row = mysql_fetch_object($sql))
  {
      echo "&lt;tr&gt;";
      echo "&lt;td&gt;$row-&gt;spmember_name&lt;/td&gt;";
      echo "&lt;td&gt;$row-&gt;present&lt;/td&gt;";
      echo "&lt;td&gt;$row-&gt;absent&lt;/td&gt;";
      echo "&lt;td&gt;$row-&gt;leave_sick&lt;/td&gt;";
      echo "&lt;td&gt;$row-&gt;business&lt;/td&gt;";
      echo "&lt;/tr&gt;";
  }
  ?&gt;
  </code></pre>
  
  <p>session_id is equal to all the ids in differnt tables namespmember1, namespmember2, namespmember3 </p>
  
  <p>Thank you for the help. </p>