-1

我一直在寻找我的问题的答案,但我找不到一个,

我正在从 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>";

在链接中,我试图通过引用输入字段的名称来传递值,但它不起作用。!

会有其他方法或有人可以解决这个问题吗?

非常感谢。

4

2 回答 2

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>";
于 2013-06-16T14:48:53.867 回答
0

您需要使用 mysql_fetch_assoc() 而不是 mysql_fetch_array

于 2013-06-16T14:38:51.233 回答