You can ORDER BY any field in the database without actually having to SELECT it.
Your example is John 14, 73, Barry 39.
I spotted the error in the first post. John (player1) scroes the 1st and third goals at 14 and 73 minutes respectively, whereas Barry only scores the second goal at minute 39.
What the poster wants to do is to ORDER by the first goal scored by each player, thus the player scoring the first goal appears first, followed by (if different) the player who scores the second goal ad finitum. However, if those players score additional goals, the poster simply wants to list the minute point WITH the first instance of the player.
I've slept on it now, and from what I can see, the only way you can do it, is with 2 sql's (someone more experienced with deeper sql's may well be able to teach me something here ;-) )
So a pseudo would take the form:
SELECT player FROM table ORDER BY goal_id GROUP BY player.
This should return an array with the players who scored goals with them in the order of their first goal.
LOOP through using a WHILE
In the WHILE add a second sql:
SELECT minute FROM table WHERE player = '$player' ORDER BY minute
Now loop through the minute markers.
close loop
close loop.
$player_result = mysql_query("SELECT player FROM table ORDER BY goal_id GROUP BY player", $db);
while ($scored = mysql_fetch_array($player_result)) {
$player_name = $scored['player'];
$minute_result = mysql_query("SELECT minute FROM table WHERE player = '$player_name' ORDER BY minute", $db);
echo $player_name;
while ($minutes = mysql_fetch_array($minute_result)) {
$minute = $minutes['minute'];
echo $minute . ", ";
};
};