Jump to content

chaulkman

New Members
  • Posts

    2
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

chaulkman's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thanks that worked. I also had a FORMAT statement in my query definition (code not displayed) that was also causing problems with calculations. Good lesson - no formatting till the end. Thanks also for the more efficient loop logic.
  2. I have a db that tracks the results of a PGA Tour golf pool. My query retrieves two fields - teamName and earnings. The code below then displays the results in a table. In the first col I've added a field called rank which displays the team ranking (1-16) . The next two cols then display the teamName and their earnings. $max equals the earnings of the first place team. With the final two cols I want to calculate (1) the difference between each team and the team in the next highest position and (2) the difference betweeen the current team and the first place team. I've tested and the variables $prevTeam and $currTeam are returning correct values. The problem occurs when I perform the math to calculate $behindLeader and $behindNextTeam. The values returned and displays are small ints (0, 2, 6, etc) instead of the correct values which should be 4,340,00 etc. Could my data types be the problem? Any help would be appreciated. [//Fetch and print all records. $rank = 1; $prevTeam = number_format ($max); //set prevTeam as $max for first pass through loop $behindNextTeam = 0; $behindLeader = 0; while ($row = mysql_fetch_array($result,MYSQL_NUM)){ $row_color = ($rowCount % 2) ? $color1 : $color2; $behindLeader = $max - $row[1]; $currTeam = $row[1]; $behindNextTeam = $prevTeam - $currTeam; echo "<tr> <td bgcolor=\"$row_color\" align=\"left\">$rank</td> <td bgcolor=\"$row_color\" align=\"left\">$row[0]</td> <td bgcolor=\"$row_color\" align=\"right\">$row[1]</td> <td bgcolor=\"$row_color\" align=\"right\">$behindNextTeam</td> <td bgcolor=\"$row_color\" align=\"right\">$behindLeader</td> </tr> \n"; $rowCount++; $rank++; $prevTeam = $row[1];]
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.