我一直在寻找我的问题的答案,但我找不到一个,
我正在从db输入数据中检索数据,并再次将输入字段中更改的值更新为db。
这是我的代码
echo "<table>";
while ($row = mysql_fetch_array($result)){
echo "<form method=\"GET\" action=\" ".htmlspecialchars($_SERVER['PHP_SELF'])."\" > ";
echo "<tr><td>ID:</td><td>Company Name</td><td>Date for Service</td><td>Edit</td><td>Delete</td></tr>";
echo "<td><input type= 'text' name = 'jobrequestnumber' value =".$row['jobrequestnumber']."></td>" ; // results in the same jobrequestnumbers
echo "<td><input type= 'text' name = 'requestingcompany' value =".$row['requestingcompany']."></td>" ;//this too
echo "<td><input type= 'date' name = 'dateforService' value =".$row['dateforService']."></td>" ;// this one also
echo "<td><a href='delete.php?jobrequestnumber=".$row['jobrequestnumber']."'>Delete</a></td>"; //too
echo "</form> ";
echo "<td><a href=\"update_request.php?jobrequestnumber='jobrequestnumber'&requestingcompany='requestingcompany'&dateforService='dateforService'\">Update</a></td>";
echo "</tr>";
}
echo "</table>";
在一个链接中,我试图通过引用输入字段的名称来传递值,但它不起作用。!
还有其他方法或有人可以解决这个问题吗?
非常感谢。
答案 0 :(得分:1)
使用post而不是get
echo "<table>";
echo "<tr><td>ID:</td><td>Company Name</td><td>Date for Service</td><td>Edit</td><td>Delete</td></tr>";
while ($row = mysql_fetch_array($result)){
echo "<form method=\"post\" action=\" ".htmlspecialchars($_SERVER['PHP_SELF'])."\" >
<input name=\"id\" type=\"hidden\" value=\"".$row['jobrequestnumber']."\">
"; // added hidden id for update
echo "<td><input type= 'text' name = 'jobrequestnumber' value =".$row['jobrequestnumber']."></td>" ; // results in the same jobrequestnumbers
echo "<td><input type= 'text' name = 'requestingcompany' value =".$row['requestingcompany']."></td>" ;//this too
echo "<td><input type= 'date' name = 'dateforService' value =".$row['dateforService']."></td>" ;// this one also
echo "<td><a href='delete.php?jobrequestnumber=".$row['jobrequestnumber']."'>Delete</a></td>"; //too
echo " ";
echo "<td><input name=\"update\" type=\"submit\" value=\"update\"></td>";
echo "</tr></form>";
}
echo "</table>";
答案 1 :(得分:0)
你需要使用mysql_fetch_assoc()而不是mysql_fetch_array