BUGFIX: wrong SQL query for min and max time of games
[e-DoKo.git] / stats.php
index 21b67ed3a7f8242a1d27e5f12711fa7f2fd05285..ba32a9269077c0954b202b96e87becfe8592c65c 100644 (file)
--- a/stats.php
+++ b/stats.php
@@ -28,7 +28,8 @@ if(myisset("logout"))
     session_unset();
     session_destroy();
     $_SESSION = array();
-    echo "you are now logged out!";
+    echo "<div class=\"message\"><span class=\"bigger\">You are now logged out!</span><br />\n".
+      "(<a href=\"$host\">This will take you back to the home-page</a>)</div>";
   }
 /* user status page */
 else if( isset($_SESSION["name"]) )
@@ -133,8 +134,10 @@ else if( isset($_SESSION["name"]) )
         echo "</p>\n";
 
         /* longest and shortest game */
-        $r=mysql_query("SELECT MIN(timediff(mod_date,create_date)),session,id".
-                       " FROM Game WHERE status='gameover' GROUP BY status");
+        $r=mysql_query("SELECT timediff(mod_date,create_date) ,session,id".
+                       " FROM Game WHERE status='gameover'".
+                       " ORDER BY time_to_sec(timediff(mod_date,create_date)) ASC LIMIT 1");
+
         if($r)
           {
             $short= mysql_fetch_array($r,MYSQL_NUM);
@@ -142,8 +145,9 @@ else if( isset($_SESSION["name"]) )
             echo "<p> The shortest game took only ".$short[0]." hours and was played by  ".join(", ",$names).".<br />\n";
           }
 
-        $r=mysql_query("SELECT MAX(datediff(mod_date,create_date)),session".
-                       " FROM Game where status='gameover' GROUP BY status");
+        $r=mysql_query("SELECT datediff(mod_date,create_date) ,session,id".
+                       " FROM Game WHERE status='gameover'".
+                       " ORDER BY time_to_sec(timediff(mod_date,create_date)) DESC LIMIT 1");
         if($r)
           {
             $long= mysql_fetch_array($r,MYSQL_NUM);
@@ -233,7 +237,8 @@ else if( isset($_SESSION["name"]) )
  else
    {
      /* send them back to the login page */
-     echo "<p>Please log in</p>";
+    echo "<div class=\"message\"><span class=\"bigger\">You need to log in!</span><br />\n".
+      "(<a href=\"$host\">This will take you back to the login-page</a>)</div>";
    }
 
 output_footer();