如何在PHP中同时满足多个“IF”?

时间:2018-02-18 17:57:39

标签: php mysql

我想解决以下问题: 我希望有人有8000个捐款,然后一个接一个地运行4个查询。

if ( ($re_config['JOIN_LEAVE_INFO'][0]['ENABLED'][0] == true) && ($aseco->startup_phase == false) ) {

    // Retrieve the amount of visits
    $visits = 0;
    $query = "
    SELECT
        `visits`,
        `mostfinished`,
        `mostrecords`,
        `donations`,
        `vipvisits`,
        `vipmostfinished`,
        `vipmostrecords`,
        `vipdonations`
    FROM `players_extra`
    WHERE `playerID`='". $player->id ."'
    LIMIT 1;
    ";
    $res = mysql_query($query);
    if ($res) {
        if (mysql_num_rows($res) > 0) {
            while ($row = mysql_fetch_object($res)) {
                $visits = $row->visits;
                $mostfinished = $row->mostfinished;
                $mostrecords = $row->mostrecords;
                $donations = $row->donations;
                $vipvisits = $row->vipvisits;
                $vipmostfinished = $row->vipmostfinished;
                $vipmostrecords = $row->vipmostrecords;
                $vipdonations = $row->vipdonations;
                //echo 'visit',$row->visits;
                //echo 'mostfin',$row->mostfinished;
                //echo 'mostreco',$row->mostrecords;
                //echo 'donat',$row->donations;


if ($donations >= 2000 && $vipdonations == 0){$res2 = mysql_query("UPDATE `players_extra` SET `vipdonations`=1 WHERE `playerID`='". $player->id ."'");
$res3 = mysql_query("UPDATE `players_extra` SET `valami2`=(`valami2`+2250) WHERE `playerID`='". $player->id ."'");
}
if ($donations >= 4000 && $vipdonations == 1){$res2 = mysql_query("UPDATE `players_extra` SET `vipdonations`=2 WHERE `playerID`='". $player->id ."'");
$res3 = mysql_query("UPDATE `players_extra` SET `valami2`=(`valami2`+2250) WHERE `playerID`='". $player->id ."'");
}
if ($donations >= 6000 && $vipdonations == 2){$res2 = mysql_query("UPDATE `players_extra` SET `vipdonations`=3 WHERE `playerID`='". $player->id ."'");
$res3 = mysql_query("UPDATE `players_extra` SET `valami2`=(`valami2`+2250) WHERE `playerID`='". $player->id ."'");
}
if ($donations >= 8000 && $vipdonations == 3){$res2 = mysql_query("UPDATE `players_extra` SET `vipdonations`=4 WHERE `playerID`='". $player->id ."'");
$res3 = mysql_query("UPDATE `players_extra` SET `valami2`=(`valami2`+2250) WHERE `playerID`='". $player->id ."'");
}
if ($donations >= 10000 && $vipdonations == 4){$res2 = mysql_query("UPDATE `players_extra` SET `vipdonations`=5 WHERE `playerID`='". $player->id ."'");
$res3 = mysql_query("UPDATE `players_extra` SET `valami2`=(`valami2`+4500) WHERE `playerID`='". $player->id ."'");
}
if ($donations >= 14000 && $vipdonations == 5){$res2 = mysql_query("UPDATE `players_extra` SET `vipdonations`=6 WHERE `playerID`='". $player->id ."'");
$res3 = mysql_query("UPDATE `players_extra` SET `valami2`=(`valami2`+4500) WHERE `playerID`='". $player->id ."'");
}
if ($donations >= 18000 && $vipdonations == 6){$res2 = mysql_query("UPDATE `players_extra` SET `vipdonations`=7 WHERE `playerID`='". $player->id ."'");
$res3 = mysql_query("UPDATE `players_extra` SET `valami2`=(`valami2`+4500) WHERE `playerID`='". $player->id ."'");
}
if ($donations >= 22000 && $vipdonations == 7){$res2 = mysql_query("UPDATE `players_extra` SET `vipdonations`=8 WHERE `playerID`='". $player->id ."'");
$res3 = mysql_query("UPDATE `players_extra` SET `valami2`=(`valami2`+4500) WHERE `playerID`='". $player->id ."'");
}
if ($donations >= 26000 && $vipdonations == 8){$res2 = mysql_query("UPDATE `players_extra` SET `vipdonations`=9 WHERE `playerID`='". $player->id ."'");
$res3 = mysql_query("UPDATE `players_extra` SET `valami2`=(`valami2`+4500) WHERE `playerID`='". $player->id ."'");
}
if ($donations >= 30000 && $vipdonations == 9){$res2 = mysql_query("UPDATE `players_extra` SET `vipdonations`=10 WHERE `playerID`='". $player->id ."'");
$res3 = mysql_query("UPDATE `players_extra` SET `valami2`=(`valami2`+6000) WHERE `playerID`='". $player->id ."'");
}
if ($donations >= 35000 && $vipdonations == 10){$res2 = mysql_query("UPDATE `players_extra` SET `vipdonations`=11 WHERE `playerID`='". $player->id ."'");
$res3 = mysql_query("UPDATE `players_extra` SET `valami2`=(`valami2`+6000) WHERE `playerID`='". $player->id ."'");
}
if ($donations >= 40000 && $vipdonations == 11){$res2 = mysql_query("UPDATE `players_extra` SET `vipdonations`=12 WHERE `playerID`='". $player->id ."'");
$res3 = mysql_query("UPDATE `players_extra` SET `valami2`=(`valami2`+12000) WHERE `playerID`='". $player->id ."'");
}
if ($donations >= 50000 && $vipdonations == 12){$res2 = mysql_query("UPDATE `players_extra` SET `vipdonations`=13 WHERE `playerID`='". $player->id ."'");
$res3 = mysql_query("UPDATE `players_extra` SET `valami2`=(`valami2`+12000) WHERE `playerID`='". $player->id ."'");
}
if ($donations >= 60000 && $vipdonations == 13){$res2 = mysql_query("UPDATE `players_extra` SET `vipdonations`=14 WHERE `playerID`='". $player->id ."'");
$res3 = mysql_query("UPDATE `players_extra` SET `valami2`=(`valami2`+12000) WHERE `playerID`='". $player->id ."'");
}
if ($donations >= 80000 && $vipdonations == 14){$res2 = mysql_query("UPDATE `players_extra` SET `vipdonations`=15 WHERE `playerID`='". $player->id ."'");
$res3 = mysql_query("UPDATE `players_extra` SET `valami2`=(`valami2`+15000) WHERE `playerID`='". $player->id ."'");
}
if ($donations >= 100000 && $vipdonations == 15){$res2 = mysql_query("UPDATE `players_extra` SET `vipdonations`=16 WHERE `playerID`='". $player->id ."'");
$res3 = mysql_query("UPDATE `players_extra` SET `valami2`=(`valami2`+20000) WHERE `playerID`='". $player->id ."'");
}

1 个答案:

答案 0 :(得分:0)

我找到了一个有效的解决方案:

    if ($donations >= 2000 && $donations !=4000){if($vipdonations == 0 ){$res = mysql_query("UPDATE `players_extra` SET `vipdonations`=1 WHERE `playerID`='". $player->id ."'");
$res = mysql_query("UPDATE `players_extra` SET `valami2`=(`valami2`+2250) WHERE `playerID`='". $player->id ."'");
$vipdonations=1;
}}
if ($donations >= 4000 && $donations !=6000){if($vipdonations == 1 ){$res = mysql_query("UPDATE `players_extra` SET `vipdonations`=2 WHERE `playerID`='". $player->id ."'");
$res = mysql_query("UPDATE `players_extra` SET `valami2`=(`valami2`+2250) WHERE `playerID`='". $player->id ."'");
$vipdonations=2;
}}
if ($donations >= 6000 && $donations !=8000){if($vipdonations ==2 ){$res = mysql_query("UPDATE `players_extra` SET `vipdonations`=3 WHERE `playerID`='". $player->id ."'");
$res = mysql_query("UPDATE `players_extra` SET `valami2`=(`valami2`+2250) WHERE `playerID`='". $player->id ."'");
$vipdonations=3;
}}
if ($donations >= 8000 && $donations !=10000){if($vipdonations ==3 ){$res = mysql_query("UPDATE `players_extra` SET `vipdonations`=4 WHERE `playerID`='". $player->id ."'");
$res = mysql_query("UPDATE `players_extra` SET `valami2`=(`valami2`+2250) WHERE `playerID`='". $player->id ."'");
$vipdonations=4;
}}
if ($donations >= 10000 && $donations !=16000){if($vipdonations ==4 ){$res = mysql_query("UPDATE `players_extra` SET `vipdonations`=5 WHERE `playerID`='". $player->id ."'");
$res = mysql_query("UPDATE `players_extra` SET `valami2`=(`valami2`+4500) WHERE `playerID`='". $player->id ."'");
$vipdonations=5;
}}
if ($donations >= 16000 && $donations !=25000){if($vipdonations ==5 ){$res = mysql_query("UPDATE `players_extra` SET `vipdonations`=6 WHERE `playerID`='". $player->id ."'");
$res = mysql_query("UPDATE `players_extra` SET `valami2`=(`valami2`+4500) WHERE `playerID`='". $player->id ."'");
$vipdonations=6;
}}
if ($donations >= 25000 && $donations !=35000){if($vipdonations ==6 ){$res = mysql_query("UPDATE `players_extra` SET `vipdonations`=7 WHERE `playerID`='". $player->id ."'");
$res = mysql_query("UPDATE `players_extra` SET `valami2`=(`valami2`+4500) WHERE `playerID`='". $player->id ."'");
$vipdonations=7;
}}
if ($donations >= 35000 && $donations !=50000){if($vipdonations ==7 ){$res = mysql_query("UPDATE `players_extra` SET `vipdonations`=8 WHERE `playerID`='". $player->id ."'");
$res = mysql_query("UPDATE `players_extra` SET `valami2`=(`valami2`+7000) WHERE `playerID`='". $player->id ."'");
$vipdonations=8;
}}
if ($donations >= 50000 && $donations !=70000){if($vipdonations ==8 ){$res = mysql_query("UPDATE `players_extra` SET `vipdonations`=9 WHERE `playerID`='". $player->id ."'");
$res = mysql_query("UPDATE `players_extra` SET `valami2`=(`valami2`+7000) WHERE `playerID`='". $player->id ."'");
$vipdonations=9;
}}
if ($donations >= 70000 && $donations !=100000){if($vipdonations ==9 ){$res = mysql_query("UPDATE `players_extra` SET `vipdonations`=10 WHERE `playerID`='". $player->id ."'");
$res = mysql_query("UPDATE `players_extra` SET `valami2`=(`valami2`+15000) WHERE `playerID`='". $player->id ."'");
$vipdonations=10;
}}
if ($donations >= 100000 && $donations !=130000){if($vipdonations ==10 ){$res = mysql_query("UPDATE `players_extra` SET `vipdonations`=11 WHERE `playerID`='". $player->id ."'");
$res = mysql_query("UPDATE `players_extra` SET `valami2`=(`valami2`+20000) WHERE `playerID`='". $player->id ."'");
$vipdonations=11;
    }}