Jump to content

Recommended Posts

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

I 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]

Link to comment
https://forums.phpfreaks.com/topic/5375-displaying-results/
Share on other sites

This will calc totals and output highest totals first

[code]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[/code]
Link to comment
https://forums.phpfreaks.com/topic/5375-displaying-results/#findComment-19430
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.