Jump to content

PHP Count - instances of a certain result - game scores


lakeshoretech

Recommended Posts

PHP/MYSQL - - -  Thank you in advance for any help.  Quick question.  I am calc'ing whether each line db output is a win/loss/tie below.  Outputting $res in each line.    Is there a simple way to COUNT the number of instances where $ res = "win" or loss or tie?

 

I'd like to put an "overall" record at the top of the output.  For example, for a given query, this chosen team's record is x WINS, Y Losses, Z TIES.  Win/Loss/Tie is NOT a field in the db table.

 

I know how to pull the total # of records pulled, but not this.

 

Example

User pulled a certain team to see game scores.

 

7 - 3 - 2 is their record. is what i'm trying to figure out

 

Game      Result      Score    Score opp    Date

game10    WIN *          7            2                blah

game11    LOSS*        2            3                ....

....

 

 //winloss begin works * above is a result of this code
    if ($row['sch_uba_score'] > $row['sch_opp_score'])
        $res = 'Win';
    elseif ($row['sch_uba_score'] < $row['sch_opp_score'])
        $res = 'Loss';
    else
        $res = 'Tie';

// winloss end works

Link to comment
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.