title: PHP Mysql joinget results
body: <p>I have 3 tables the <strong>subject</strong>, <strong>student</strong>, and <strong>relation</strong><br>
  The following are sample data</p>
  
  <pre>
  students table
  id    name
  1     John
  2     Doe
  3     Jane
  
  subject table
  id    subject
  1     Math
  2     Science
  3     English
  
  relation table
  id    student_id    subject_id
  1       1                1
  2       1                3
  3       2                1
  4       1                2
  </pre>
  
  <p>in this case sudent with <strong>id=1</strong> has <strong>3 subjects</strong>. How can I get result like this?</p>
  
  <pre>
  student name is John
  subjects are:
  Math
  Science
  English
  </pre>
  
  <p>I already get the values for student, what I'm trying to do is get his subject to be shown by user.
  I'm totally confused using join tables. I'm a newbie in php and I start learning this last week. I'm getting an error on my code. Please help.<br>
  My Cuurent code is this:</p>
  
  <pre>
  &lt;?php
  //mysql connection
  
  $query = "
    SELECT *,* FROM relation, subject
    on subject_id = id
    WHERE student_id = $student_id
  ";
  $result = mysql_query($query);
  ?>
  Student name is &lt;?php echo $name ?>&lt;br />
  Subjects are:&lt;br />
  &lt;?php
  while($row = mysql_fetch_array($result)) {
    echo $row["subject"];
  }
  ?>
  </pre>