[snip]
First thanks for your answer and your help. I would like to explore this
concept
of using the PHP. I mean, I've already coded some small games in C++,
and
implementing a game loop is kinda easy, since you have the control of
all the
data being processed. But PHP scripts, as I currently know of, are only
run when
requested by the client, and the when they finish execution then they're
gone. I
never tried, but could it be done a game loop in PHP? I mean like a
script I
would start and it would keep running constantly, checking for new
commands in a
queue, updating objects status, can it be done or the server would kill
it?
[/snip]
You can set a while(TRUE) loop. Here is an example of one that I use to
monitor a condition in a database and update an IFRAME. This has a 10
second sleep cycle.
while(TRUE){
$getNotesCount = "SELECT COUNT(*) AS entries FROM test.tblTNotes
";
if(!($dbNotesCount = mysql_query($getNotesCount, $dbc))){
echo mysql_error() . "\n";
exit();
}
$value = mysql_fetch_array($dbNotesCount);
$newValue = $value['entries'];
if(!(isset($currentValue)) || ($currentValue != $newValue)){
$currentValue = $newValue;
?>
<form name="foo" action="stateTestData.php"
method="POST" target="bottomFrame">
</form>
<script language="javascript">
foo.submit();
</script>
<?php
flush();
ob_end_flush();
}
sleep(10);
}
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php