動的に作成された入力フィールドからデータベース内の複数の行を正常に更新する方法について、いくつかのアドバイスが必要です。
だから、私が持っているのはこれです:
PHP
<?php
while ($row = mysql_fetch_array($sql)) {
echo "<input class='estemated_days' type='text' id='".$row['scpe_id']."' value='".$row['scpe_estemated_days']."'></td>";
}
?>
これは次のようなものを出力します:
HTML
<input class='estemated_days' type='text' id='718' value='5'>
<input class='estemated_days' type='text' id='719' value='8'>
<input class='estemated_days' type='text' id='720' value='10'>
<input type='button' id='save' value='Save'> <!-- Button to jQuery -->
.....等。
これが私の知識が不足しているところです。jQueryに次のようなことをさせたい:
jQuery
($"#save").click(function () {
// Get value of id from (".estemated_days") as an identifier, and get the input value it contains
// Send to /update.php
});
次に、次のupdate.php
ようなことを行います:
PHP
<?php
if (isset($_POST['save'])) {
/*
Get all of the id's and the value it contain's
perform:
*/
mysql_query = ("UPDATE myDatabase SET estemated_days = '$the_value_from_the_input' WHERE scpe_id = '$the_value_of_the_id'");
//Repeat this for all rows from the webpage
}
?>
私の知識は基本的なWebプログラミングですが、これを機能させたいと思っています。誰かが私がそれをどのようにすべきかについてアドバイスを受けましたか?