I need help again. OK I have my code set up to display like I want it, but now I have come across a new problem. I am going to make it so that when you click a team name, it will take you to an information page about that team. I am also going to make it so that when you click a players name, it takes you to a page about that player. Now my problem is, that it uses the index table to determine the ID at the end of the URL. BUT, The coaches index number must come from th coach table and the players index number must come from the players table, but since I did a left join for comparison reasons, it is querying both indexes wich creates a problem for my links! The only index I seem to be able to get results from is my coache table index, so my team links work fine. Here is an example of one of my player links:
<td><a href="http://mysite/player_info.php?id=<?php echo $row_data['index']; ?>"><?php echo $row_data['player_name']; ?></a></td>
This method makes it link to the team page, since it is only recognising the coach index. I tried this:
<td><a href="http://mysite/player_info.php?id=<?php echo $row_data['players.index']; ?>"><?php echo $row_data['player_name']; ?></a></td>
And when I do that, no number appears at the end. So I tried doing a seperate query for only the index of the player and when I do that, and change the link to reflect it, thet all just link to player.index 1 instead of linking to thier respective index number like they should. Here is most of my script:
$query_data = "SELECT * FROM players left join coaches on players.index = coaches.index where players.avail = 'yes'ORDER BY coach_name";
$data = mysql_query($query_data, $dbConnect) or die(mysql_error());
$row_data = mysql_fetch_assoc($data);
$totalRows_data = mysql_num_rows($data);
?>
<html>
<head>
<title>Available Players</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?php
$last_coach_name = '';
do {
?>
<?php if ($row_data['coach_name'] != $last_coach_name) { ?>
<p><?php echo $row_data['subname']; ?><br>
<?php echo $row_data['city']; ?>, <?php echo $row_data['state']; ?><br>
Contact Name: <?php echo $row_data['contact_name']; ?> Telephone: <?php echo $row_data['contact_tel']; ?><br>
Email: <?php echo $row_data['lead_email']; ?> Fax: <?php echo $row_data['contact_fax']; ?></p>
<?php }
$last_coach_name = $row_data['coach_name'] ?>
<table width="75%" border="0">
<tr bgcolor="#1C213D">
<td><font color="#FFFFFF">Player Name</font></td>
<td><font color="#FFFFFF">Hits</font></td>
<td><font color="#FFFFFF">Scores</font></td>
<td><font color="#FFFFFF">Outs</font></td>
<td><font color="#FFFFFF">Address</font></td>
<td><font color="#FFFFFF">Phone Number</font></td>
<td><font color="#FFFFFF">Available</font></td>
</tr>
<tr>
<td><?php echo $row_data['player_name']; ?></td>
<td><?php echo $row_data['hits']; ?></td>
<td><?php echo $row_data['scores']; ?></td>
<td><?php echo $row_data['out']; ?></td>
<td><?php echo $row_data['address']; ?></td>
<td><?php echo $row_data['lot']; ?></td>
<td><?php echo $row_data['phone']; ?></td>
<td><?php echo $row_data['avail']; ?></td>
</tr>
</table>
<?php } while ($row_data = mysql_fetch_assoc($data)); ?>
<p></p>
</body>
</html>
<?php
mysql_free_result($data);
?>
Also, I can't change the name of the index of either table.