2014-04-28 124 views
1

我試圖用jQuery數據表基於一些標籤顯示圖像。基於標籤顯示圖像 - jQuery Datatables

   <?php 
       while ($row = mysql_fetch_array($result2)) { 
        ?> 
        <tr> 
         <td><?=$row['IP']?></td> 
         <td><?=$row['Agent']?></td> 
         <td><?=$row['Verified']?></td> 

         if($row['Label'] == "Other"){ 
         <td><img src="imgb.png"></td> 
         } 
         else{ 
         <td><img src="imgc.png"></td> 
         } 

        </tr> 
       <?php 
       } 
       ?> 

問題是'如果部分'不工作,它只顯示所有的兩個圖像。 而且它回聲如下。

if($row['Label'] == "Other"){ } else{ } if($row['Label'] == "OtherCrawler"){ } else{ } if($row['Label'] == "OtherCrawler"){ } else{ } 

這裏有什麼問題?請考慮我對php/jQuery有點新鮮感。

+0

你依然 「在PHP」 當你做'如果($行[ '標籤'] == 「其他」){​​'你需要回顯。 I.e .:'echo'​​';' –

+0

@ Fred-ii-我認爲這與你所說的相反。 OP忘了聲明php。 –

+0

是的,你是對的。 @ PoomrokcThe3years –

回答

2

因爲你需要開始PHP代碼之前,如果

<?php if($row['Label'] == "Other"){ ?> <td><img src="imgb.png"></td> <?php } else{ ?> <td><img src="imgc.png"></td> <?php } ?>

+0

感謝朋友,它工作得很好。 :) –

1
  <?php 
       while ($row = mysql_fetch_array($result2)) { 
       ?> 
       <tr> 
        <td><?=$row['IP']?></td> 
        <td><?=$row['Agent']?></td> 
        <td><?=$row['Verified']?></td> 
        <?php 
        if($row['Label'] == "Other"){ 
        ?> 
        <td><img src="imgb.png"></td> 
       <?php } 
        else{ 
        <td><img src="imgc.png"></td> 
        } 
        ?> 
       </tr> 
      <?php 
      } 
      ?> 
0

上面的回答是圖像顯示,當它返回使用 過了一會/換每個從數據庫中循環。但是當我們使用 ssp.customized.class文件時,它將不會被使用。