在我的代码中,可以在下面找到,我让服务器检查这个人是否在团队中。如果它们是,它会显示某些东西,如果它们不显示某些不同的东西。如果这个人在团队中(它打印正确的东西),它会起作用,但如果该团队不在团队中,则不会显示任何内容。有什么帮助吗?
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/>';
}
}
}
答案 0 :(得分:0)
为什么不像这样简单检查
if(isset($players) && $players < 1){
$team = "You are not a team";
}else{
..
}