Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can try to correct somme errors first, as it's difficult to see PHP script errors when called with AJAX.</p> <p>As all records are in a single form, we must identify each record individually like "<strong>user-field123-updated</strong>":</p> <p>js:</p> <pre><code>$(".listen").keyup(function() { var myname = $(this).attr("name"); if(! myname.match(/updated/i)) { $(this).attr("name", myname + "-updated"); } }) </code></pre> <p>HTML while () {} loop, user name will be identified by user-field123:</p> <pre><code>&lt;form action="post"&gt; &lt;?php while($rows=mysql_fetch_array($result)) { ?&gt; &lt;tr&gt; &lt;td&gt;Whatever this row name is: &lt;?php echo $rows['Name']; ?&gt; &lt;input type="hidden" name="ID" value="&lt;?php echo $rows['ID']; ?&gt;&lt;/td&gt; &lt;td&gt;The editable field: &lt;input class="listen" type="text" name="user-field&lt;?php echo $rows['ID']; ?&gt;" size="4" value="&lt;?php echo $rows['Users']; ?&gt;"&gt;&lt;/input&gt;&lt;/td&gt; &lt;/tr&gt; &lt;?php } ?&gt; &lt;input type="submit" name="submit-button" value="Click to update only fields I changed"&gt;&lt;/input&gt; &lt;/form&gt; </code></pre> <p>PHP to save in DB, syntax:</p> <pre><code>// // Users table $tbl_name must be set before: // if(isset($_POST['submit-button'])) { // // IDs is an array: // $IDs = $_POST['ID']; foreach($IDs as $ID) { if(isset($_POST['user-field' . $ID . '-updated'])){ $value = $_POST['user-field' . $ID . '-updated']; $sql = "UPDATE $tbl_name SET Users = '$value' WHERE id = $ID"; $q = $db-&gt;prepare($sql); $q-&gt;execute(); } } }; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload