title: updating multiple rows using one form
body: <p>I am trying to update twelve rows at once. I searched around different ways of doing this but none of them worked with me. I don't see any action happening when I press "Submit". Can anybody help me finding what is wrong in below script:</p>
  
  <pre><code>&lt;?php
  include 'connection.php';
  
  $sql="SELECT * FROM tbl_maint_track1";
  $result=mysql_query($sql);
  
  // Count table rows 
  $count=mysql_num_rows($result);
  $sno = array(); 
  ?&gt;
  &lt;table width="500" border="0" cellspacing="1" cellpadding="0"&gt;
  
  &lt;form name="form1" method="post" action=""&gt;
  &lt;tr&gt; 
  &lt;td&gt;
  &lt;table width="500" border="0" cellspacing="1" cellpadding="0"&gt;
  
  
  &lt;tr&gt;
  &lt;td align="center"&gt;&lt;strong&gt;S No&lt;/strong&gt;&lt;/td&gt;
  &lt;td align="center"&gt;&lt;strong&gt;Qty&lt;/strong&gt;&lt;/td&gt;
  &lt;td align="center"&gt;&lt;strong&gt;Maint Catgry&lt;/strong&gt;&lt;/td&gt;
  &lt;td align="center"&gt;&lt;strong&gt;Uprice&lt;/strong&gt;&lt;/td&gt;
  &lt;td align="center"&gt;&lt;strong&gt;Tprice&lt;/strong&gt;&lt;/td&gt;
  
  &lt;/tr&gt;
  &lt;?php
  while($rows=mysql_fetch_array($result)){
  ?&gt;
  &lt;tr&gt;
  &lt;td align="center"&gt;&lt;? $sno[]=$rows['sno']; ?&gt;&lt;? echo $rows['sno']; ?&gt;&lt;/td&gt;
  &lt;td align="center"&gt;&lt;input name="qty[]" type="text" id="qty" value="&lt;? echo $rows['qty'];         ?&gt;"&gt;&lt;/td&gt;
  &lt;td align="center"&gt;&lt;input name="maint_catgry[]" type="text" id="maint_catgry" value="&lt;?     echo    $rows['maint_catgry']; ?&gt;"&gt;&lt;/td&gt;
  &lt;td align="center"&gt;&lt;input name="uprice[]" type="text" id="uprice" value="&lt;? echo        $rows['uprice']; ?&gt;"&gt;&lt;/td&gt;
  &lt;td align="center"&gt;&lt;input name="tprice[]" type="text" id="tprice" value="&lt;? echo        $rows['tprice']; ?&gt;"&gt;&lt;/td&gt;
  
  &lt;/tr&gt;
  &lt;?php
  }
  ?&gt;
  &lt;tr&gt;
  &lt;td colspan="4" align="center"&gt;&lt;input type="submit" name="Submit" value="Submit"&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;/table&gt;
  &lt;/td&gt;
  &lt;/tr&gt;
  &lt;/form&gt;
  &lt;/table&gt;
  &lt;?php
  
  $sno = $_POST['sno']; 
  $qty = $_POST['qty']; 
  $maint_catgry = $_POST['maint_catgry']; 
  $uprice = $_POST['uprice']; 
  $tprice = $_POST['tprice']; 
  
  // Check if button name "Submit" is active, do this 
  if(isset($_POST["$Submit"])){
  for($i=0;$i&lt;$count;$i++){
  $sql1= "UPDATE tbl_maint_track1 SET qty = '{$qty[$i]}', maint_catgry = '{$maint_catgry[$i]}', uprice         = '{$uprice[$i]}', tprice = '{$tprice[$i]}' WHERE sno = '{$sno[$i]}' "; 
  $result1=mysql_query($sql1);
  }
  }
  
  if($result1){
  echo "Thanks, $count records updated";
  }
  else
  {
  echo "No record updated";
  }
  close_conn();
  ?&gt;
  </code></pre>
  
  <p>Is there a better way to update multiple record with one form?</p>
  
  <p>Thanks in advance.</p>