is it possible to output the "this doesn't output" before the while-loop starts, and also while it loops?
i use output buffering.
session[pid] is playerid
session[gid] is gameid
tpr2.php is the script, could possibly replace it with php_self, but that's not the point
//if it's not your turn, loop until it is and redirect to this page again
if(!turn()) {
echo "this doesn't output";
while(!turn()) {
echo "this doesn't output either<br>";
}
header ("Location: tpr2.php");
} else {
board();
}
this is the function that is looped:
function turn() {
// fetch the turn-field in the table for the current game
$sql = "SELECT turn FROM anders_tpr WHERE gid = '".$_SESSION['gid']."'";
$result = mysql_query($sql) or die(mysql_error());
$whose_turn = mysql_result($result, 0);
// if your playerid equals turn, it's your turn, else: it's your opponents turn
if($_SESSION['pid'] == $whose_turn) {
return true;
} else {
return false;
}
}