not relooping
Posted: Wed Dec 09, 2009 10:31 am
Hello
I have this script going
everything like $user_id is declared
so the problem is its not relooping
i have more then one entries in the database it only performs actions on one at file execution(like a queue) which is not what i want
Where did i go wrong?
I have this script going
Code: Select all
$query = "SELECT `building_id`, `amount`, `ticks` FROM `game_resource_build` WHERE `user_id` = '$user_id'";
$result = mysql_query($query);
while($row = mysql_fetch_assoc($result)){
$building_id = $row['building_id'];
$amount = $row['amount'];
$ticks = $row['ticks'];
echo "Bid: $building_id";
echo "\n";
echo "Amount: $amount";
echo "\n";
echo "Ticks: $ticks";
echo "\n";
if($ticks > 0){
$query = "UPDATE `game_resource_build` SET `ticks`= `ticks`-1 WHERE `building_id` = '$building_id' AND `user_id` = '$user_id' AND `ticks` > 0";
mysql_query($query);
$query = "SELECT `ticks` FROM `game_resource_build` WHERE `building_id` = '$building_id' AND `user_id` = '$user_id' AND `ticks` = 0 LIMIT 1";
$result = mysql_query($query);
$newticks = mysql_num_rows($result);
if($newticks == 1){
$query = "INSERT INTO `game_resource_buildings` (`user_id`, `building_id`, `amount`) VALUES ('$user_id', '$building_id', '$amount')";
mysql_query($query);
$query = "DELETE FROM `game_resource_build` WHERE `building_id` = '$building_id' AND `user_id` = '$user_id' AND `ticks` = 0";
mysql_query($query);}}
}so the problem is its not relooping
i have more then one entries in the database it only performs actions on one at file execution(like a queue) which is not what i want
Where did i go wrong?