看板 PHP 關於我們 聯絡資訊
※ 引述《LAOS (LAOS)》之銘言: : echo "<tr align='center' bgcolor='#EDEAB1'>"; : echo "<td>" . $row["hello"] . "</td>"; : echo "</tr>"; : echo "</form>"; : 如上,從資料庫提出hello欄位的值,然後列出,我要在值加上超連結 : 用<a href=""></a>怎麼擺都沒辦法,有其他解? <tr align="center" bgcolor = "#EDEAB1"> <td><a href="xxxx.xxx"><?=$row['hello']?></a></td> </tr> 如果你把echo拿掉,會不會做起來就比你想像的輕鬆的多? 切記一件事:php的echo輸出就是html,既然如此就不需要把html「又」echo一次。 另外如果伺服器預設不支援short tag的話。 就要改成<?php echo $row['hello']?> 如果遇到重複的區段html: foreach(xxxxx as $row){ echo "<tr align='center' bgcolor = '#EDEAB1'>"; echo "<td><a href='xxxx.xxx'>{$row['hello']}</a></td>"; echo "</tr>"; } 改成這樣會顯得比較不會雜亂: <?php foreach(xxxx as $row):?> <tr align="center" bgcolor = "#EDEAB1"> <td><a href="xxxx.xxx"><?=$row['hello']?></a></td> </tr> <?php endforeach;?> -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 59.104.131.10