On Wed, Feb 4, 2009 at 17:24, tedd <[email protected]> wrote:
[snip!]
>
> I understand that I can have one record set up for each tutor, and another
> record set up for each course, and then tie the two together by another
> record like an assignment. That way I can have as many assignments as I want
> tying courses to tutors.
>
> It that the way you guys would do it?
I would, yes. Very basically:
database.tutors:
id INT(8) NOT NULL auto_increment
f_name VARCHAR(32)
l_name VARCHAR(32)
database.courses
id INT(8) NOT NULL auto_increment
class_name VARCHAR(90)
class_description MEDIUMTEXT
database.course_tutors
id INT(8) NOT NULL auto_increment
tutor_id INT(8)
course_id INT(8)
Then just run the query you want based on the following example:
<?php
// Database includes, etc....
$sql = "SELECT course_name,course_description FROM courses WHERE id ";
$sql .= "IN (SELECT course_id FROM course_tutors WHERE tutor_id=";
$sql .= "'".mysql_real_escape_string($_GET['tutor_id'])."')";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result)) {
echo "Class: ".$row['course_name']."<br />\n";
echo "Description: ".$row['course_description']."<br />\n";
}
?>
You can also use JOINs and so forth, of course, but a simple
WHERE/IN should be fine.
--
</Daniel P. Brown>
[email protected] || [email protected]
http://www.parasane.net/ || http://www.pilotpig.net/
Unadvertised dedicated server deals, too low to print - email me to find out!
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php