0
這是我的最後一個問題數據無法採訪了到數據庫的PHP - 編輯後 -
https://stackoverflow.com/questions/6233894/data-can-not-be-intered-to-database-php
我做了一些變化,這兩種;包含文本框和操作頁面的頁面。
在第一頁,我所做的文本框具有與每個迴路不同的名稱:
$count1=100;
$count2=200;
$count3=300;
$count4=400;
echo "<form action='ConfirmEnter.php' method='post'>";
echo "<table border cellpadding=3>";
echo "<tr>";
echo "<th>ID</th>";
echo "<th>MidTerm</th>";
echo "<th>Project</th>";
echo "<th>Final</th>";
echo "<th>Total</th>". "</tr>";
while($row1 = mysql_fetch_array($result1))
{
echo "<tr>";
echo "<td><input name='".$count1."' readonly='readonly' value='". $row1['ID'] ."' size=5/></td> ";
echo "<td><input type='text' name='".$count2."' size=5 value='0.0' /></td>";
echo "<td><input type='text' name='".$count3."' size=5 value='0.0' /></td>";
echo "<td><input type='text' name='".$count4."' size=5 value='0.0' /></td>";
echo "</tr>";
$count1++;
$count2++;
$count3++;
$count4++;
}
echo "</table>";
echo "<input type='submit' value='Submit' />";
echo "</form>";
在操作頁面:
$count=1;
$count1=100;
$count2=200;
$count3=300;
$count4=400;
function addtwo($a = 0.0 , $b = 0.0 , $c = 0.0)
{
return ($a + $b + $c);
}
while($row1 = mysql_fetch_array($result1))
{
$id[$count] = $_POST['$count1'];
$mt[$count] = $_POST['$count2'];
$pr[$count] = $_POST['$count3'];
$fi = $_POST['$count4'];
$tot[$count] = addtwo($mt[$count]+$pr[$count]+$fi);
echo $fi;
mysql_query("INSERT INTO Marks (ID, Name, MidTerm, Project, Final, Total)
VALUES ('$id[$count]', 'EMPTY', '$mt[$count]', '$pr[$count]', '$fi', '$tot[$count]')");
$count++;
$count1++;
$count2++;
$count3++;
$count4++;
}
的問題仍然是相同的。數據不能被插入到數據庫中。 我通過使用echo語句打印每一行,我finaaly發現,當我打印$ _POST的語句它不打印任何東西(如你可以看到在代碼中有回聲$ fi)