Many-to-Many confusion...
Posted: Wed Jan 06, 2010 9:41 am
Hi all,
newb here learning as I go.
I've got a many-to-many db in which students, courses, course description and tutor
have relationships.
I'm trying to learn how to display various queries (and not doing very well).
My query looks like this:
I want to display a list of courses that the member has signed up to.
So in the body of the html I tried this:
but it only lists one course that the member has signed up (and I know the member is signed up to three).
Any ideas ?
Best wishes
Monty
newb here learning as I go.
I've got a many-to-many db in which students, courses, course description and tutor
have relationships.
I'm trying to learn how to display various queries (and not doing very well).
My query looks like this:
Code: Select all
$id = mysql_real_escape_string($id);
$id = eregi_replace("`", "", $id);
$query = sprintf("SELECT c.* FROM students_to_courses stc INNER JOIN courses c ON stc.course_fk = c.course_id WHERE stc.student_fk = '$id'");
$result = mysql_query($query);
while ($row = mysql_fetch_assoc($result)) {
$tutor = $row['tutor_fk'];
$course_name = $row['course_name'];
$course_descriptoin = $row['course_description'];
}
So in the body of the html I tried this:
Code: Select all
<td colspan="4"><span class="orangeText"><?php print_r ("$course_name"); ?></span></td>
Any ideas ?
Best wishes
Monty