我希望程序忽略零总数。我试图停止向总数为零的非参与者提供自动奖励。我在&&运算符之后添加了> =表达式。这对杀人和净资产是否正确?

    $fetch_nor_killers = mysql_query("SELECT wk,bk,hk,dk,pk,mk, code, p, (wk+bk+hk+dk+pk+mk) as totalKills FROM r$round[round]_p WHERE status = '". normal ."' ORDER BY totalKills DESC LIMIT 3");
    $killa_rank = 0;

    while($killa = mysql_fetch_array($fetch_nor_killers))
    {
        $killa_rank++;

        if($killa_rank == 1 && $killa['totalKills'] >= 1)
        {
            $killa_award = "freeopkiller1";
        }
        else
        if($killa_rank == 2 && $killa['totalKills'] >= 1)
        {
            $killa_award = "freeopkiller2";
        }
        else
        if($killa_rank == 3 && $killa['totalKills'] >= 1)
        {
            $killa_award = "freeopkiller3";
        }


与networth一样。只是试图避免授予未激活的用户。 @Jagrut

        $fetch_top_subs = mysql_query("SELECT * FROM r$round[round]_p WHERE subscription != '". none ."' ORDER BY  networth DESC LIMIT 3");
     $sub_rank = 0;

     while($sub = mysql_fetch_array($fetch_top_subs))
    {
         $sub_rank++;

        if($sub_rank == 1 && $sub_rank['networth'] >= 1)
        {
         $sub_award = "first_sub";
        }
        else
        if($sub_rank == 2 && $sub_rank['networth'] >= 1)
        {
         $sub_award = "second_sub";
        }


即将测试这些。

最佳答案

首先,我希望您对这个问题更加清楚。但是据我了解,这可能是您的代码存在的问题:

您正在直接使用$totalKills。您可以将其分配给变量然后使用它,或者需要使用$killa来访问$totalKills,即

用作:

$anyVar = $killa['totalKills'];


然后使用$anyVar进行操作,或直接使用$killa['totalKills']代替$totalKills

希望这会有所帮助。

08-18 14:27