Here's an example. You'll have to modify this to suit your needs.
List states
$query = mysql_query("SELECT id, state FROM states ORDER BY state");
while( $row = mysql_fetch_object( $query ) )
{
print '<a href="stateDetail.php?stateID=' . $row->id . '">' . $row->State . "</a><br />\n";
}
stateDetail.php (listing of colleges in that state)
if( !isset( $_GET['stateID'] ) )
{
print 'No State Selected';
}
else
{
$id = (int) $_GET['stateID'];
// Substitute c.name for whatever the name of your field is in your table that holds
// The name of the college
$query = mysql_query("
SELECT c.id
, c.name
FROM states AS s
INNER
JOIN colleges AS c
ON c.state_id = s.id
WHERE s.id = " . $id . "
ORDER
BY c.name"
);
if( mysql_num_rows($query) == 0 )
{
print 'No Colleges listed in this state';
}
else
{
while( $row = mysql_fetch_object( $query ) )
{
print '<a href="collegeDetail.php?collegeID=' . $row->id . '">' . $row->name . "</a><br />\n";
}
}
}
you can make collegeDetail.php based on these examples.
None of this is tested and I likely made a mistake somewhere. Just sift through it and play around - you should get the general concept from this.