//Set the http variables $action = $_REQUEST["action"]; $boxid = $_REQUEST["boxid"]; if($action=="remove"){ // Get the box place of the guy who is being removed. $oldboxplaceresult = db_query("SELECT boxrank FROM tblBoxLeagues WHERE boxid = $boxid AND siteid = ".get_siteid()." "); $boxrankval = mysqli_result($oldboxplaceresult, 0); //Remove Box $qid1 = db_query("UPDATE tblBoxLeagues SET tblBoxLeagues.enable = FALSE WHERE boxid = $boxid"); //Set all current reservations for this box to practice. $historyQuery = "SELECT reservationid from tblBoxHistory WHERE boxid = $boxid"; $historyResult = db_query($historyQuery); while($historyArray = mysqli_fetch_array($historyResult)){ markMatchType($historyArray[reservationid],0); } //Finally Clean up with box league history $qid1 = db_query("DELETE FROM tblBoxHistory WHERE boxid = $boxid"); // Now adjust all boxes who were ranked below this box $adjustquery = "SELECT tblBoxLeagues.boxid, tblBoxLeagues.boxrank FROM tblBoxLeagues WHERE (((tblBoxLeagues.boxrank)>$boxrankval)) AND siteid=".get_siteid()." AND tblBoxLeagues.enable = TRUE ORDER BY tblBoxLeagues.boxrank"; // run the query on the database $adjustresult = db_query($adjustquery); //Update the rankings while ($adjustobj = db_fetch_object($adjustresult)) { $newboxrankval = $adjustobj->boxrank - 1; $qid = db_query(" UPDATE tblBoxLeagues SET boxrank = '$newboxrankval' WHERE boxid = '$adjustobj->boxid'"); } } if($action=="disable"){ //Remove Buddy $qid1 = db_query("UPDATE tblBoxLeagues SET tblBoxLeagues.enable = 0 WHERE tblBoxLeagues.boxid=$boxid"); } if($action=="enable"){ //Remove Buddy $qid1 = db_query("UPDATE tblBoxLeagues SET tblBoxLeagues.enable = 1 WHERE tblBoxLeagues.boxid=$boxid"); } //Move a box up if($action=="moveup"){ // Get the box place of the guy who is being removed. $oldboxrankresult = db_query("SELECT boxrank FROM tblBoxLeagues WHERE boxid = $boxid"); $boxrankval = mysqli_result($oldboxrankresult, 0); // Get around the problem of moving up a box who is in first if ( $boxrankval > 1){ $newboxrankval = $boxrankval - 1; // MOve the box ahead down $qid1 = db_query(" UPDATE tblBoxLeagues SET boxrank = '$boxrankval' WHERE boxrank = '$newboxrankval' AND siteid = ".get_siteid().""); //echo "Moved the box ahead down one from $boxrankval to $newboxrankval.\n\n"; // MOve the box up $qid2 = db_query(" UPDATE tblBoxLeagues SET boxrank = '$newboxrankval' WHERE boxid = $boxid AND siteid = ".get_siteid().""); //echo "Moved me box ahead up one from $newboxrankval on box $boxid\n"; } } $clubquery = "SELECT timezone from tblClubs WHERE clubid=".get_clubid().""; $clubresult = db_query($clubquery); $clubobj = db_fetch_object($clubresult); $gmtime = time(); $tzdelta = $clubobj->timezone*3600; $curtime = $gmtime+$tzdelta; ?>