seany123 Posted November 26, 2008 Share Posted November 26, 2008 right so im making a game and the code your about to see is a basic code to update some of the players values... money and city_id. <?php header("location: home.php"); include("lib.php"); $player = check_user($secret_key, $db); ?> <?php $query = $db->execute("update `players` set `money`=?, `city_id`=2 where `id`=?", array($player->money - 1000, $player->id )); ?> The help i need is.... im wanting to make it so if the $player has less than 1000 money and/or city_id = 2.... then it would just do the redirect without doing the query. how do i do this??? Quote Link to comment https://forums.phpfreaks.com/topic/134410-help-with-php-code/ Share on other sites More sharing options...
Maq Posted November 26, 2008 Share Posted November 26, 2008 Is this what you mean... include("lib.php"); $player = check_user($secret_key, $db); if($player->money city_id == 2) { header("location: home.php"); } else { $query = $db->execute("update `players` set `money`=?, `city_id`=2 where `id`=?", array($player->money - 1000, $player->id )); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/134410-help-with-php-code/#findComment-699748 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.