I am trying to create e dynamic table where data will be fetched and I can edit any value I want
<p>I can fetch the data but the submit button is not working.
 I am confused with the update query and storing data in array.
Here is the code for fetching and showing data in table.</p>

<pre><code>     `&lt;?php
           while ($rows=mysqli_fetch_assoc($result)){ ?&gt;
               &lt;tr&gt;
               &lt;td align="center"&gt;
               &lt;?php $id[]=$rows['id']; ?&gt;&lt;?php echo $rows['id']; ?&gt;
               &lt;/td&gt;
               &lt;td align="center"&gt;  
               &lt;input name="name[]" type="text" id="name" value="&lt;?=$rows['name']; ?&gt;"&gt;
               &lt;/td&gt;
               &lt;td align="center"&gt;
               &lt;input name="lastname[]" type="text" id="lastname" value="&lt;? =$rows['lastname']; ?&gt;"&gt;
               &lt;/td&gt;
               &lt;td align="center"&gt;
               &lt;input name="email[]" type="text" id="email" value="&lt;?=$rows['email']; ?&gt;"&gt;
               &lt;/td&gt;
               &lt;/tr&gt;
</code></pre>



<p>

 `</p>

<p>Here is the code for submit button</p>

<pre><code>if ($_SERVER["REQUEST_METHOD"] == "POST" &amp;&amp; $_POST["Submit"] != ""){
    $count = mysqli_num_rows($result);
        for($i=0;$i&lt;$count;$i++){
            $sql2="UPDATE test_mysql SET name='".$_POST["name"][$i]."',lastname='".$_POST["lastname"][$i]."', email='".$_POST["email"][$i]."' WHERE id='$id[$i]'";
            $result1=mysqli_query($con, $sql2);
        }
header("Location: update-multiple-2.php");
</code></pre>

<p>}</p>