0

在下面可以找到的代码中,我让服务器检查此人是否在团队中。如果是,它会显示一些东西,如果不是,它会显示一些不同的东西。如果这个人在一个团队中,它会起作用(它打印正确的东西),但如果这个人不在一个团队中,它不会显示任何内容。有什么帮助吗?

            if($_SESSION["username"]){
                $sql2 = mysql_query("SELECT * FROM teams WHERE game='bl2' AND players LIKE '%$sessiongamt%'") or die("Could not allocate information!");
                $num1 = 0;
                while($row = mysql_fetch_assoc($sql2)){
                  $num = ++$num;
                  $amount = mysql_num_rows($sql2);
                  $id = $row["id"];
                  $name = $row["name"];
                  $link = $row["link"];

                  if($amount < 0 || $num1 < 0){
                    print '<hr/>
                      <img src="../../img/games/black-ops-2-img.png" />
                      <h2>Black Ops 2: XBOX360</h2>
                      <hr/>
                        <div class="btn-group" style="margin-left: 210px;">
                          <a href="../findamatch.php?g=bl2" class="btn">Find a Match</a>
                          <a href="../reportamatch.php?g=bl2" class="btn">Report a Match</a>
                          <a href="../matchissue.php?g=bl2" class="btn">Match Issue</a>
                          <a href="../support.php?id=bl2" class="btn">Support</a>
                        </div>
                      <hr/>
                      <h2>Featured Teams</h2><hr/>';
                  }else{
                    print '<hr/>
                      <img src="../../img/games/black-ops-2-img.png" />
                      <h2>Black Ops 2: XBOX360</h2>
                      <hr/>
                        <div class="btn-group" style="margin-left: 210px;">
                          <a href="../findamatch.php?g=bl2" class="btn">Find a Match</a>
                          <a href="../reportamatch.php?g=bl2" class="btn">Report a Match</a>
                          <a href="../matchissue.php?g=bl2" class="btn">Match Issue</a>
                          <a href="../support.php?id=bl2" class="btn">Support</a>
                        </div>
                      <hr/>
                      <h2>Featured Teams</h2><hr/>';
                  }
              }
            }
4

1 回答 1

0

为什么不进行这样的简单检查

if(isset($players) && $players < 1){
  $team = "You are not a team";
}else{
.. 
}
于 2013-03-25T02:08:27.567 回答