2012-03-31 84 views
0

我正在運行遊戲服務器併爲我的遊戲服務器製作了一張顯示您的項目的表格。 該表清除了它,但問題是有一個名爲「GMP」的項目是垃圾郵件的名單,因爲人們得到它很多。如何從我的表格中排除某個名稱

我想要做的是從整個表格中排除項目「GMP」,但我無法從表格中取出。

http://puu.sh/nefH。這是它的樣子。 這是源代碼的一部分,讓它展示這一點。

print <<<END 
<br> 
<table border="1"> 
<tr> 
<th>Item</th> 
<th>+</th> 
<th>Damage -</th> 
<th>Extra hp</th> 
<th>Position</th> 
</tr> 
END; 


$sql6 = "SELECT t.name, i.position, p.position, i.type, i.magic3, i.reduce_dmg, i.add_life FROM cq_item i, position p, cq_itemtype t WHERE t.id = i.type AND p.id = i.position AND player_id = $id2 ORDER BY name ASC"; 
$execute6 = mysql_query($sql6); 
while ($exibir6 = mysql_fetch_array($execute6)){; 

print "<tr>"; 

print "<td>".$exibir6 ['name']."</td>"; 
print "<td>".$exibir6 ['magic3']."</td>"; 
print "<td>".$exibir6 ['reduce_dmg']."</td>"; 
print "<td>".$exibir6 ['add_life']."</td>"; 
print "<td>".$exibir6 ['position']."</td>"; 

print "</tr>"; 


} 
print <<<END2 
</table> 
END2; 

如果還有其他需要告訴我,我會將它添加到這裏。

對不起,我的英語不是我的母語。

+0

我想知道爲什麼數據仍然存在,如果它不應該顯示。你有沒有任何理由不刪除它們? – 2012-03-31 12:29:03

回答

1

不要選擇使用該名稱(使用WHERE爲)項目:

$sql6 = " 
    SELECT t.name, i.position, p.position, i.type, i.magic3, i.reduce_dmg, i.add_life 
    FROM cq_item i, position p, cq_itemtype t 
    WHERE t.id = i.type AND p.id = i.position AND player_id = $id2 AND t.name != 'GMP' 
    ORDER BY name ASC"; 

NB。我希望你能逃脫/投你的查詢變量if語句正確

+0

感謝您真正快速的回答。這對我有效。其餘的一切都是正常和正常工作。再次感謝。 – Arthur1472 2012-03-31 12:27:40

1
$sql6 = "SELECT t.name, i.position, p.position, i.type, i.magic3, i.reduce_dmg, i.add_life FROM cq_item i, position p, cq_itemtype t WHERE t.id = i.type AND p.id = i.position AND player_id = $id2 AND t.name != 'GMP' ORDER BY name ASC"; 
0

不要在你的循環。

<?php 
while ($exibir6 = mysql_fetch_array($execute6)){ 
    if($exibir6['name'] != 'GMP') { 
    // Add to table 
    } 
} 
?> 
相關問題