BUGFIX: wrong DB query returned sometime less rows than expected
authorArun Persaud <arun@nubati.net>
Thu, 17 Jul 2008 00:20:18 +0000 (17:20 -0700)
committerArun Persaud <arun@nubati.net>
Thu, 17 Jul 2008 00:20:18 +0000 (17:20 -0700)
this fixes a bug on the home page where, in case no game was in the pre-game phase, the ongoing games were listed as games being started and the completed games were listed as ongoing games.

Signed-off-by: Arun Persaud <arun@nubati.net>
include/welcome.php

index 5436ecf5f1015902f4d0f1a84907b7b53ad33a72..654e968faf5ccb2b15d16b9b02fc639830d3a5b3 100644 (file)
@@ -9,12 +9,15 @@ if(!isset($HOST))
 
 $pre[0]=0;$game[0]=0;$done[0]=0;
 
-$r=DB_query("SELECT COUNT(id) FROM Game GROUP BY status");
-if($r) {
-  $pre  = DB_fetch_array($r);
-  $game = DB_fetch_array($r);
-  $done = DB_fetch_array($r);
- }
+$r=DB_query("SELECT COUNT(*) FROM Game where status='pre'");
+if($r)  $pre  = DB_fetch_array($r);
+
+$r=DB_query("SELECT COUNT(*) FROM Game where status='play'");
+if($r)  $game  = DB_fetch_array($r);
+
+$r=DB_query("SELECT COUNT(*) FROM Game where status='gameover'");
+if($r)  $done  = DB_fetch_array($r);
+
 
 $r=DB_query("SELECT AVG(datediff(mod_date,create_date)) FROM Game where status='gameover' ");
 if($r)