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 に答える