CincoPistolero Posted March 20, 2006 Share Posted March 20, 2006 I have four columns: score_gross1, score_gross2, score_gross3, score_gross4I have a select statement: [code]SELECT * FROM pt_stats WHERE tourn_id='$tourn_id' AND score_wd = '0' AND score_dq = '0' ORDER BY `score_gross1` ASC LIMIT 0,1 [/code]I would like to display the order from day to day by adding the columns together, not just by one column. Something like below.[code]$er_roundttl = $score_gross1 + $score_gross2 + $score_gross3 + $score_gross4;[/code]Is there anyway to work this into the SELECT statement? Is there any other way to do this.Below is the code I use to display the results.[code]while ( $rowpl= mysql_fetch_array($resultpl)){extract($rowpl); $row_color = ($row_count % 2) ? $color1 : $color2; /*$er_roundttl = $score_gross1 + $score_gross2 + $score_gross3 + $score_gross4;*/ $place = $row_count + 1; echo "<tr class='$row_color'>\n"; echo "<td align='center'>$place</td>\n"; echo "<td width='30%'><a href='../statistics/playerstats.php?player_id=$player_id'>$pt_player_name</a></td>\n"; echo "<td>$score_gross1</td>\n"; echo "<td>$score_gross2</td>\n"; echo "<td>$score_gross3</td>\n"; echo "<td>$score_gross4</td>\n"; echo "<td>$er_roundttl</td>\n"; echo "<td>$$score_money.00</td>\n"; echo "<td>$score_tpoints</td>\n"; echo "</tr>\n"; $row_count++;} ?>[/code] Quote Link to comment Share on other sites More sharing options...
Barand Posted March 21, 2006 Share Posted March 21, 2006 This will calc totals and output highest totals first[code]SELECT *, (score_gross1 + score_gross2 + score_gross3 + score_gross4) AS roundTotalFROM pt_stats WHERE tourn_id='$tourn_id' AND score_wd = '0' AND score_dq = '0' ORDER BY roundTotal DESC[/code] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.