-1

質問に対する答えを探していましたが、見つかりませんでした。

データベースから入力フィールドにデータを取得し、入力フィールドの変更された値をデータベースに再度更新しています。

これが私のコードです

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

get の代わりに post を使用する

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_array ではなく mysql_fetch_assoc() を使用する必要があります

于 2013-06-16T14:38:51.233 に答える