Win Loss Stats Table

I’m currently building a clan match area for my clan and have made progress with the pages i’m making. The next thing on my list is how to create a table of stats from the database entries I have.

Each match has score for and against, also different types of matches.

what I’d like to try to generate is a table with

4v4
8v8
12v12
16v16
Other
Totals

Each with Win loss and draw for them.

Is this something easy enough to do or will it require a lot of queries to the database?

Very hard to say without knowing your code and your mysql tables and fields

I’ve more than a few fields int he table, but the only 2 that are going to be needed at this time are

winloss which has 3 options “Win,Loss,Draw”
complete which has 2 options “Yes,No”

It would also need to check 2 further table entries for the name “UKE” so it coulds home and away which as the field names as well

So I’d like to have it post something like this

Clan Name Wins / Loss / Draws / Total
UKE 3 1 0 4

I’ve no base code other than to count the rows in the tabel atm as i’ve no clue where to start with it. I’ll update this once i’ve found something to play with

ok so been messing about with this and i’ve got an output for the total of wins/loss/draws and also total number of complete games.

Would I need to add in a further check on the queries to make sure either home team (home) and away team (away) have the name UKE in them?

[php]<?php

// DB connection
include_once ‘connect2.php’;

$title = "Show match report";
include_once 'header.php';

$resulta = mysql_query("SELECT * FROM ukematch WHERE winloss='Win'");
$num_rowwin = mysql_num_rows($resulta);

$resultb = mysql_query("SELECT * FROM ukematch WHERE winloss='Loss'");
$num_rowloss = mysql_num_rows($resultb);

$resultc = mysql_query("SELECT * FROM ukematch WHERE winloss='Draw'");
$num_rowdraw = mysql_num_rows($resultc);

$resultd = mysql_query("SELECT * FROM ukematch WHERE complete='Yes'");
$num_rowtotal = mysql_num_rows($resultd);

echo “$num_rowwin, $num_rowloss, $num_rowdraw, $num_rowtotal”;

?>[/php]

I think you would be better off with mysql_array

[php]
$resulta = mysql_query(" SELECT winloss,complete FROM ukematch WHERE winloss=‘Win’ " );

while ($row = mysql_fetch_array($resulta)) {
echo ‘
’;
echo 'winloss : '.$row[‘winloss’];
echo ’      ';
echo ‘complete :’.$row[‘complete’];
echo ‘
’;
}
[/php]

not getting emails on replies on this thread this time. I’m sure there was a better way to code it. but I got it working and looking how I wanted.

Codes not prety but works. I used a lot of queries like this one below to get the output i needed.
[php] $resulta = mysql_query(“SELECT * FROM ukematch WHERE winloss=‘Win’ && matchtype=‘Friendly 4v4’”);
$num_rowwin4 = mysql_num_rows($resulta);[/php]

With just updating the code to make sure nothing over lapped.

Sponsor our Newsletter | Privacy Policy | Terms of Service