I'm a novice so sorry if I get some terms wrong. Can somebody help me with how to code a specific part of php for my many-to-many mySQL relationship. I'll make this the simplest example I can so I can learn how it's basically done (rather than just taking the code and not learning for myself). Lets say...
I have one table that lists leagues in town
league_id || league_name
1 || Alpha League
2 || Beta League
I have another table that lists ballfields in town
field_id - field_name
1 || X Field
2 || Y Field
3 || Z Field
Now I haven't made it yet but I suspect that I'll need an intermediate table like this. Lets say the Alpha League plays on every field in town but the Beta League only plays on the Z field.
league_id || field_id
1 || 1
1 || 2
1 || 3
2 || 3
So far so good, right? Okay, so now I've got all my mySQL tables setup right (I hope), but I don't know how to do the php coding that utilizes this relationship on a webpage. With only one table I can easily display all the data about the Alpha League by using code similar to this:
<?
$db = mysql_connect("localhost", "xxx", "xxx");
mysql_select_db("league_database",$db);
$result = mysql_query("SELECT * FROM league_table WHERE id=$id",$db);
$myrow = mysql_fetch_array($result);
print $myrow["tableinfo1"]."<br />";
print $myrow["tableinfo2"]."<br />";
print $myrow["tableinfo3"]."<br />";
..........and so forth.........
?>
But aside from listing info from just this single league_table, how would I list info from the fields_table too? In other words, how do I list on this same webpage that the Alpha League plays at X Field, Y Field, and Z Field? (fields is on a 2nd table and the relationship table is a 3rd table) What is the basic coding for how to display this data? Thank you so much for your help!