2014-08-28 81 views
-2

我正在查詢我的數據庫並獲取需要在我的網頁上打印的值。在HTML中打印php值

  <div class="col-6 col-middle"> <span class="h4"> <a href="#" class="text-normal">**A**</a> </span> 
      <div class="actions row-space-top-1"> <a href="#">**B**</a> </div> 
      <div class="actions row-space-top-1"> <b>Duration:</b>**C**</div> 
      <div class="actions row-space-top-1"> <b>Travel date:</b>**D**</div> 
      </div> 

現在,我已經提到的A,B,C,d我需要打印我的PHP值...

 while($row = mysql_fetch_array($result, MYSQL_ASSOC)) 
     { 
      echo "Name :{$row['A']} <br> ". 
       "Date_Of_Travel : {$row['B']} <br> ". 
       "No_Of_Days : {$row['C']} <br> "; 

     } 

此外,我需要循環的HTML代碼中,我有很多行。

輸出應該看起來像 enter image description here

請指導。

+0

所以你正在尋找一個模板框架/庫?這種行爲在PHP中不是本地的。 – Sugar 2014-08-28 13:26:36

+0

嘗試將數據作爲某種類型的html對象和使用css的對象樣式回顯。 – Blubberguy22 2014-08-28 13:27:38

+0

沒有像框架/庫。一些正常的邏輯,可以使其工作? – Newibe 2014-08-28 13:28:15

回答

2
while($row = mysql_fetch_array($result, MYSQL_ASSOC)) 
    { 
    ?> 
     <div class="col-6 col-middle"> <span class="h4"> <a href="#" class="text-normal"><?php echo $result['a'] ?></a></span> 
     <div class="actions row-space-top-1"> <a href="#"><?php echo $result['B'] ?></a> </div> 
     <div class="actions row-space-top-1"> <b>Duration:</b><?php echo $result['C'] ?></div> 
     <div class="actions row-space-top-1"> <b>Travel date:</b><?php echo $result[D'] ?></div> 
     </div> 
    <?php 
    } 
+0

這不起作用 – Newibe 2014-08-29 04:35:28

+0

你回來了什麼?任何錯誤? – 2014-08-29 04:40:56

+0

屏幕上沒有任何東西 – Newibe 2014-08-29 04:47:27