title: Updating multiple records in mySQL table via PHP web form table?
body: <p>Need a little help...</p>
  
  <p>I have a basic html table with text field form in last column and a hidden field on each row of the web table.  The data in this table is extracted out of a table in the database. </p>
  
  <p>I want my users to be able to update one field in the database (a score)  using this web form (page).</p>
  
  <p>I have a hidden web form component on each row that contains the unique id of the record in the database for each row in the web page table.</p>
  
  <p>I was attempting to create code that would   update the entire list of entries on the web form, even if the user is not updating that particular field. (The values of the scores field are populated into the web form at the creation of the table. So if you did not update any scores, but hit the submit button, it would update the database table with the same values.)</p>
  
  <p>Here’s my code: (abbreviated to save bytes…)</p>
  
  <pre><code>&lt;?php
  
  //Do all the database connection stuff up front
  
  
  if (isset($_POST[‘score’]))
  {
       $student_id = $_POST[‘student_id’];
        $score = $_POST['score'];
        $n        = count($score);
         $i        = 0;
  
  echo "You have updated these student scores on this assignment. \r\n" .
  "&lt;ol&gt;";
     while ($i &lt; $n)
  {
  echo "&lt;hr&gt;&lt;P&gt;{$score[$i]} \r\n";
  echo "&lt;hr&gt;&lt;P&gt;{$student_id[$i]} \r\n";
  
  $qry = "UPDATE assignments SET score = ".$score[$i]." WHERE student_id = " .$student_id[$i]. '"';
  $result=@mysql_query($qry);
  
  $i++;
     }
  }
  if($result) {
          header("location: member-index.php");
          exit();
      }else {
          die("Query failed");
      }
  ?&gt;
  </code></pre>
  
  <p>Am I on the right track? Is there a better way to do what I’m attempting? All suggestions and ideas welcome!</p>
  
  <p>Thank you in advance!</p>