PHP でのテーブルの作成に関して支援が必要です。私のコードでは、テーブルが何度も印刷されています。何らかの理由で、コードの出力は、結果の数のカウントが ^2 であるものです。したがって、実際のデータベースに 4 つの結果がある場合、出力には 16 の結果があります。フォーラムに投稿する前にもう少し調査を行いたいのですが、私は PHP が初めてで、どこから始めればよいかわかりません。
//Count the number of rows returned
$count = mysql_num_rows($result);
echo $count;
//Table header
echo "<div><table id=\"tableheader\" bgcolor=\"#4382b5\">\n";
echo "<tr>\n";
echo "<td> 3-4 ID:</td>\n";
echo "<td> First Name:</td>\n";
echo "<td> Last Name:</td>\n";
echo "<td> HCA:</td>\n";
echo "<td> File:</td>\n";
echo "<tr>";
echo "</table></div>";
if ($count !== 0) {
while($row = mysql_fetch_array($result)) {
echo "<div class=\"addform\"><form method='get' action=\"update.php\">\n";
echo " <input type=\"text\" value=\"".$row['tfid']."\" name=\"column1\">\n";
echo " <input type=\"text\" name=\"column2\" value=\"".$row['fname']."\"/>\n";
echo " <input type=\"text\" name=\"column3\" value=\"".$row['lname']."\"/>\n";
echo " <input type=\"text\" name=\"column4\" value=\"".$row['hca']."\"/>\n";
echo " <input type=\"text\" name=\"column5\" value=\"".$row['file']."\"/>\n";
echo " <input type=\"image\" src=\"images/update.png\" alt=\"Update Row\" class=\"update\" title=\"Update Row\">\n";
echo "<a href=\"delete.php?tfid=".$row['tfid']."\"><img title='Delete Row' alt=\"Delete\" class='del' src='images/delete.png'/></a></form></div>\n";
}
echo "</table><br />\n";
} else {
echo "<b><center>NO DATA</center></b>\n";
}