Jump to content

Counting help please :)


jmcall10

Recommended Posts

Hi, I have the following:

 

$rows = $sql->execute ( "SELECT playerid,SUM(points) AS points FROM ".$score_table."  GROUP BY playerid ORDER BY points DESC", SQL_RETURN_ASSOC ) or die ("$DatabaseError");   
echo "<table><tr><td>Pos.</td><td>Player</td><td>Played</td><td>Won</td><td>Points</td></tr>";
    $num = sizeof ( $rows );      
      for ( $i = 0; $i < $num; ++$i )
      {
	$points = $rows [ $i ] [ "points" ];
	$playerid = $rows [ $i ] [ "playerid" ];
	$pos = $i + 1;
echo "<tr>
<td>$pos</td>
<td>$playerid"</td>	  
<td align=\"center\"></td>
<td align=\"center\"></td>
<td align=\"center\">$points</td>
</tr>";

 

 

Now my points table looks like this:

 

id, playerid, tournamentid, points, dateadded

 

As I hope you can see I ahve added two column, one us "Played", and the other is "Won"

 

At the moment the above query sorts out who has the most points and orders them accordingly.

 

What I want to add in is the details of these two columns.

 

Could someone please assist :)

 

Thanks in advance

 

jmcall10

 

Link to comment
Share on other sites

I have managed to sort out the how many times people have played column.

 

Can someone please assist with a query that will be able to show how many times they have won.

 

To break the tables down for you.

 

Basically there is the score table which has the following fields:

id, playerid, tournamentid, points, dateadded,

 

So a player can play in many tournaments and will get points. They may win a tournament therefore would have the most points allocated to them under that tournament.

 

So what I guess I need the query to do is work out how many times someone has been allocated the most points.

 

thanks in advance

 

jmcall10

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.