Im trying to total the wins and losses on one field.
Heres what ive got so far.
<?
include ("config.php3");
$connection = mysql_connect("$dbhost","$dbusername","$dbpasswd") or die ("Couldn't connect to server.");
$db = mysql_select_db("$database_name", $connection) or die("Couldn't select database.");
$sql = "SELECT , count() AS cnt
FROM phplog
GROUP BY field9
Order BY cnt
DESC
";
$counter = 0;
$LoseCounter = 0;
$WinCounter = 0;
$res = mysql_query($sql) or die(mysql_error());
if(mysql_num_rows($res) > 0) {
// Outputs Table etc... (Removed)
while($row=mysql_fetch_array($res)) {
$Name = $row['field6'];
if ( $Name == "Win") {
$WinCounter= $WinCounter + 1;
}
if ( $Name == "Lose") {
$LoseCounter= $LoseCounter + 1;
}
echo "<tr>";
$counter= $counter +1;
$ID1 = $row['field9'];
/// Displays results in Table (removed)
Echo $LoseCounter;
Echo $WinCounter;
echo $Counter;
echo "</tr>";
} echo "</table>";
}
else {
echo "No records found ";
}
?>
Ive removed the html etc, so the thread isnt to long. THe results from $losecounter and $wincounter are way out. What am i doing wrong. Is there an easier way to do this?