Note that there are some explanatory texts on larger screens.

plurals
  1. POupdate table in mysql with dynamically created input field from database
    primarykey
    data
    text
    <p>I want to update fields in database. here is the code in which i fetch the records from database and show them in a form.</p> <pre><code>&lt;form name="create_album" method="POST" action="" style="width:auto;"&gt; &lt;label for="First Name"&gt;Album Name&lt;/label&gt; &lt;input type="text" name="album" id="album" placeholder="Album Name"value="&lt;?php echo $album_name; ?&gt;" /&gt; &lt;?php $result = mysql_query("select * from user_uploads where album = '$album_name' "); while($row=mysql_fetch_array($result)) { ?&gt; &lt;img src="&lt;?php echo $row['image_name']; ?&gt;" height="140" width="140" /&gt; &lt;input type="text" name="des[]" value="&lt;?php echo $row['image_description']; ?&gt;" placeholder="Image Description Here"/&gt; &lt;input type="text" name="id[]" value="&lt;?php echo $row['id']; ?&gt;" placeholder="Image Description Here"/&gt; &lt;?php } ?&gt; &lt;input type="submit" name="submit" value="Upload Album"/&gt; </code></pre> <p></p> <p>but now when i want to update the records in database it update all the records into the table with the value of last input field. here is the php code.</p> <pre><code> &lt;?php if(IsSet($_POST["submit"])) { $album = $_POST["album"]; $des=$_POST["des"]; foreach($_POST['id'] as $id) { $update_qry = "update user_uploads set album='$album', image_description='$des' where id = '$id' "; $result_update_image = mysql_query($update_qry); if (!$result_update_image) { header("location:create_album.php?errmsg=Album Not Updated"); } } } } ?&gt; </code></pre> <p>But i dont know how to get all the values of des form array to update in table according to id.</p>
    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.
 

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