title: Updating multiple rows in sql and php
body: <p>I have a table , that needs to update specific rows.The user ticks(using checkbox) which value to update and this is then sent as an array (the two values) This value(s) then needs to be changed in the database.The problem is it updates both values with the same. i need both values to be different based on whats coming in from the post array </p>
  
  <p>I am not sure if i should use a join? or a for loop? </p>
  
  <p>How do you go about updating multiple values coming in  from a checkbox array? . All i want is for it to update both values based on the POST array values.The correct values are coming in from post array as i used var_dump </p>
  
  <pre><code>foreach($_POST['course_id'] as $course_id) {
  
      $update_query = "UPDATE course_student SET course_id='$course_id' WHERE student_id='$student_id' ORDER BY course_id";
      $update_course_result = mysqli_query($connection,$update_query);
  
      if($update_course_result &amp;&amp; mysqli_affected_rows($connection)&gt;0) {
          echo "Success";
          // more code here
      }
  
  }
  </code></pre>