Ho scritto così:
Codice PHP:
$sq = mysql_query("SELECT * FROM edifici WHERE id='".$ed."' ") or die (mysql_error());
$build = mysql_fetch_array($sq);
$ownoro = $resrow['oro'];
$time = $build['time'];
$end = time() + $time;
$ver = true;
$act = mysql_query("SELECT * FROM azioni WHERE utente = '".$id."' ") or die (mysql_error());
while ($action = mysql_fetch_array($act)) {
if ($action['fine'] > time()) {
$ver = false;
} }
if (($resrow['oro'] >= $build['oro']) && ($ver == true)) {
$ownoro = $ownoro - $build['oro'];
$Query = mysql_query("UPDATE utenti SET oro = '".$ownoro."' WHERE id = '".$id."' ") or die (mysql_error());
$strQuery = mysql_query("INSERT INTO costruiti (edificio, utente, liv) values ('".$ed."', '".$id."', '".$liv."')") or die(mysql_error());
$costruzione = mysql_query("INSERT INTO azioni (edificio, utente, fine) values ('".$ed."', '".$id."', '".$end."')") or die(mysql_error());
}
Il problema è che però la verifica effettuata dall'if non funzioni, perchè se dopo aver fatto costruire l'edificio immediatamente dopo ne faccio costruire un altro questo non viene bloccato.