I've listed a function below that I can't understand what is wrong. In the function there are 3 queries. The first 2 work, but the last returns the wrong data.
I first query how many rounds a player has played & store it in $row. I then use that value in the next query which stores another number in $row2. These work fine. When I then try to use $row2 in the $results3 query, I get the wrong data.
Here is an example of the whole picture. I have a player who has 3 scores in the rounds table. Based on this, I query the handicap_table to get the correlating number for 3, which is 2 (rounds to count). I then try & select their best 2 total scores into an array (the number of scores used is based on the second query). The three values in total column of the rounds table for that player are 41,39,41. The 3rd query seems to be returning what the first query retreived (3 & 3 are the results of the third query).
Any help is greatly appreciated.
Thanks,
Jason Martin
function GetHandicap ($player_name)
{
global $dbname;
$results=mysql($dbname,"select count(*) as count from rounds where name = '$player_name'");
$row=mysql_result($results,"count");
$results2=mysql($dbname,"select rounds_used from handicap_table where rounds = $row");
$row2=mysql_result($results2,"rounds_used");
$results3=mysql($dbname,"select total from rounds where name = '$player_name' order by total asc LIMIT $row2");
while($row3=mysql_fetch_array($results3)) {
$handicap.=$row[$total].'<br>';
}
return $handicap;
}
echo GetHandicap("Brian Martin");