if(myisset("followup") )
{
$followup= $_REQUEST["followup"];
- mysql_query("INSERT INTO Game VALUES (NULL, NULL, '$randomNRstring', 'normal', NULL,'1','pre','$followup' ,NULL)");
+ $session = DB_get_session_by_gameid($followup);
+ if($session)
+ mysql_query("INSERT INTO Game VALUES (NULL, NULL, '$randomNRstring', 'normal', NULL,'1','pre','$session' ,NULL)");
+ else
+ {
+ /* get max session */
+ $max = DB_get_max_session();
+ $max++;
+ mysql_query("INSERT INTO Game VALUES (NULL, NULL, '$randomNRstring', 'normal', NULL,'1','pre','$max' ,NULL)");
+ mysql_query("UPDATE Game SET session='".$max."' WHERE id=".DB_quote_smart($followup));
+ }
}
else
mysql_query("INSERT INTO Game VALUES (NULL, NULL, '$randomNRstring', 'normal', NULL,'1','pre', NULL ,NULL)");
while( $r = mysql_fetch_array($result,MYSQL_NUM))
echo " FINAL SCORE: ".$r[0]." ".$r[1]."<br />";
- /* suggest a new game with the same people in it, just rotated once */
- $names = DB_get_all_names_by_gameid($gameid);
- output_ask_for_new_game($names[1],$names[2],$names[3],$names[0],$gameid);
+
+ $session = DB_get_session_by_gameid($gameid);
+ $result = mysql_query("SELECT id,create_date FROM Game".
+ " WHERE session=$session".
+ " ORDER BY create_date DESC".
+ " LIMIT 1");
+ $r=-1;
+ if($result)
+ $r = mysql_fetch_array($result,MYSQL_NUM);
+
+ if(!$session || $gameid==$r)
+ {
+ /* suggest a new game with the same people in it, just rotated once */
+ $names = DB_get_all_names_by_gameid($gameid);
+ output_ask_for_new_game($names[1],$names[2],$names[3],$names[0],$gameid);
+ }
}
break;
default: