Jump to content


Photo

Displaying Results


  • Please log in to reply
1 reply to this topic

#1 CincoPistolero

CincoPistolero
  • Members
  • PipPipPip
  • Advanced Member
  • 118 posts
  • LocationEl Dorado Hills, California

Posted 20 March 2006 - 10:55 PM

I have four columns: score_gross1, score_gross2, score_gross3, score_gross4

I have a select statement:

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

I would like to display the order from day to day by adding the columns together, not just by one column. Something like below.

$er_roundttl = $score_gross1 + $score_gross2 + $score_gross3 + $score_gross4;

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.

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++;}
        ?>



#2 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,017 posts

Posted 21 March 2006 - 07:35 PM

This will calc totals and output highest totals first

SELECT *, (score_gross1 + score_gross2 + score_gross3 + score_gross4) AS roundTotal
FROM pt_stats 
WHERE tourn_id='$tourn_id' 
    AND score_wd = '0' 
    AND score_dq = '0' 
ORDER BY roundTotal DESC

If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users