summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArun Persaud <arun@nubati.net>2007-07-29 19:17:51 -0700
committerArun Persaud <arun@nubati.net>2007-07-29 19:21:30 -0700
commit8c9f2736384c0c279019ca41c32da58e127bf572 (patch)
treeee9894bb22f60c7e936848595d5c830bd8c140de
parent2e9d5e97305ccbd1b975013511922f924d53fffd (diff)
downloade-DoKo-8c9f2736384c0c279019ca41c32da58e127bf572.tar.gz
e-DoKo-8c9f2736384c0c279019ca41c32da58e127bf572.tar.bz2
e-DoKo-8c9f2736384c0c279019ca41c32da58e127bf572.zip
BUGFIX: order games by session
games are now ordered by sessions, also fixed a typo
-rw-r--r--db.php7
-rw-r--r--index.php13
2 files changed, 13 insertions, 7 deletions
diff --git a/db.php b/db.php
index 867be16..a6b9c3b 100644
--- a/db.php
+++ b/db.php
@@ -907,9 +907,10 @@ function DB_format_gameid($gameid)
$session = DB_get_session_by_gameid($gameid);
/* get number of game */
- $result = mysql_query("SELECT COUNT(*),create_date FROM Game WHERE session='$session' ".
- " GROUP by session".
- " HAVING TIMEDIFF(create_date, (SELECT create_date FROM Game WHERE id='$gameid'))<=0");
+ $result = mysql_query("SELECT COUNT(*),create_date FROM Game".
+ " WHERE session='$session' ".
+ " AND TIMEDIFF(create_date, (SELECT create_date FROM Game WHERE id='$gameid'))<=0 ".
+ " GROUP by session");
$r = mysql_fetch_array($result,MYSQL_NUM);
return $session.".".$r[0];
diff --git a/index.php b/index.php
index 57145c6..cfef15b 100644
--- a/index.php
+++ b/index.php
@@ -1721,10 +1721,11 @@ else if( myisset("email","password") || isset($_SESSION["name"]) )
echo "<p>These are your games that haven't started yet:<br />\n";
$result = mysql_query("SELECT Hand.hash,Hand.game_id,Game.mod_date,Game.player from Hand".
" LEFT JOIN Game On Hand.game_id=Game.id".
- " WHERE Hand.user_id='$uid' AND Game.status='pre'" );
+ " WHERE Hand.user_id='$uid' AND Game.status='pre'".
+ " ORDER BY Game.session" );
while( $r = mysql_fetch_array($result,MYSQL_NUM))
{
- echo "<a href=\"".$host."?me=".$r[0]."\">game".DB_format_gameid($r[1])." </a>";
+ echo "<a href=\"".$host."?me=".$r[0]."\">game ".DB_format_gameid($r[1])." </a>";
if($r[3]==$uid || $r[3]==NULL)
echo "(it's <strong>your</strong> turn)\n";
else
@@ -1744,7 +1745,8 @@ else if( myisset("email","password") || isset($_SESSION["name"]) )
echo "<p>These are the games you are playing in:<br />\n";
$result = mysql_query("SELECT Hand.hash,Hand.game_id,Game.mod_date,Game.player from Hand".
" LEFT JOIN Game On Hand.game_id=Game.id".
- " WHERE Hand.user_id='$uid' AND Game.status='play'" );
+ " WHERE Hand.user_id='$uid' AND Game.status='play'".
+ " ORDER BY Game.session" );
while( $r = mysql_fetch_array($result,MYSQL_NUM))
{
echo "<a href=\"".$host."?me=".$r[0]."\">game ".DB_format_gameid($r[1])." </a>";
@@ -1769,7 +1771,10 @@ else if( myisset("email","password") || isset($_SESSION["name"]) )
echo "<p>And these are your games that are already done:<br />Game: \n";
$output = array();
- $result = mysql_query("SELECT hash,game_id from Hand WHERE user_id='$uid' AND status='gameover'" );
+ $result = mysql_query("SELECT hash,game_id from Hand".
+ " LEFT JOIN Game ON Game.id=Hand.game_id".
+ " WHERE user_id='$uid' AND Game.status='gameover'".
+ " ORDER BY Game.session,Game.create_date" );
while( $r = mysql_fetch_array($result,MYSQL_NUM))
$output[] = "<a href=\"".$host."?me=".$r[0]."\">".DB_format_gameid($r[1])." </a>";
echo implode(", ",$output)."</p>\n";