变量$ Item成功递增,而另一个变量$ Item2保持为“2”,我不知道为什么它以2开头。
下面是它的截图。
这是代码
$itemQuery = $this->DBase('Query', array( 0 => "SELECT * FROM `items`" ));
while ($GETITEM = $itemQuery->fetch_object()) {
$itemrewardQuery = $this->DBase('Query', array( 0 => "SELECT * FROM `quests_rewards` WHERE QuestID = $id" ));
while ($QUESTITEM = $itemrewardQuery->fetch_object()) {
$Item = $GETITEM->id;
$Item2 = $QUESTITEM->ItemID;
if($Item == $Item2){
$temp .= '<td>'. $GETITEM->Name .'<span class="label label-success pull-right">TAKEN</span></td>';
} else {
$temp .= '<td>'. $GETITEM->Name .'</td>';
};
}
echo "{$temp}";
}
答案 0 :(得分:0)
$itemQuery = $this->DBase('Query', array( 0 => "SELECT * FROM `items`" ));
while ($GETITEM = $itemQuery->fetch_object()) {
$itemrewardQuery = $this->DBase('Query', array( 0 => "SELECT * FROM `quests_rewards` WHERE QuestID = $id" ));
while ($QUESTITEM = $itemrewardQuery->fetch_object()) {
$Item = $GETITEM->id;
$Item2 = "";
$Item2 = $QUESTITEM->ItemID;
if($Item == $Item2){
$temp .= '<td>'. $GETITEM->Name .'<span class="label label-success pull-right">TAKEN</span></td>';
} else {
$temp .= '<td>'. $GETITEM->Name .'</td>';
};
}
echo "{$temp}";
}
在分配新值之前使$ item2 =“”。 我认为这应该有效。请试试。