我是進一步學習PHP的幾個階段,但我已經到了另一個惱人的進站點。我有一個非常簡單的代碼從我的數據庫中檢索書籍項目。我將它們顯示在html表中,但是因爲它是一個循環,所以如果我使用表標題的第th標記,我會在每個數據項上獲得一個標題!PHP循環 - 使用循環創建表格併爲其添加標題
這裏是我的代碼片段:(你可以看到我已經把我的th標籤的意見爲不工作)
<table border="0">
<br />
<?php
$count = 0;
while ($count < $numrow)
{
$row = mysql_fetch_array($results);
extract($row);
echo "<tr>";
//echo "<tr>";
//echo "<th>";
//echo "Book Title";
//echo "</th>";
//echo "<th>";
//echo "Book Author";
//echo "</th>";
//echo "<th>";
//echo "Book Publisher";
//echo "</th>";
//echo "<th>";
//echo "Book ISBN";
//echo "</th>";
//echo "</tr>";
echo "<td>";
echo "<a href='addtolist.php? bookname=".$bookname."&bookauthor=".$bookauthor."&bookpub=".$bookpub."&bookisbn=".$bookisbn."'>[+]</a>";
echo "</td>";
echo "<td>";
echo $bookname;
echo "</td>";
echo "<td>";
echo $bookauthor;
echo "</td>";
echo "<td>";
echo $bookpub;
echo "</td>";
echo "<td>";
echo $bookisbn;
echo "</td>";
echo "<td>";
echo "<a href='deletecd.php?bookname=".$bookname."'>Delete</a>";
echo "</td>";
echo "</tr>";
$count = $count + 1;
}
?>
只要我發佈問題,我注意到了,會刪除br ..謝謝你的迴應,只要它允許我也會打勾你的回答!非常感謝[= – Phil 2012-02-21 21:30:36
這就是它通常發生的情況! ;) – jprofitt 2012-02-21 22:09:24