title: How to update multiple rows in one query (using for loop)
body: <p>For example, I have two data on my table:<br><br>
  |&nbsp;&nbsp;&nbsp;ID&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;Name&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;Age&nbsp;&nbsp;&nbsp;|<br></p>
  
  <hr>
  
  <p>|&nbsp;&nbsp;&nbsp;1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;Steve&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;25&nbsp;&nbsp;&nbsp;&nbsp;|<br>
  |&nbsp;&nbsp;&nbsp;2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;Bob&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;28&nbsp;&nbsp;&nbsp;&nbsp;|<br><br>
  When i updating one value (for example: change "Bob" to "George"), it changes all value. This is the result:<br>
  |&nbsp;&nbsp;&nbsp;ID&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;Name&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;Age&nbsp;&nbsp;&nbsp;|<br></p>
  
  <hr>
  
  <p>|&nbsp;&nbsp;&nbsp;1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;George&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;28&nbsp;&nbsp;&nbsp;&nbsp;|<br>
  |&nbsp;&nbsp;&nbsp;2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;George&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;28&nbsp;&nbsp;&nbsp;&nbsp;|<br><br></p>
  
  <p>How to updating multiple rows in one query? To collect values, I use for loop like this:</p>
  
  <pre><code>&lt;?php
  ...
  $id_array = $_POST['id'];
  $name_array = $_POST['name'];
  $age_array = $_POST['age'];
  
  $id = array();
  $name = array();
  $age = array();
  
  for ($i = 0; $i &lt; count($id_array); $i++) {
  //count($id_array) --&gt; if I input 4 fields, count($id_array) = 4)
  
     $id[] = mysql_real_escape_string($id_array[$i]);
     $name[] = mysql_real_escape_string($name_array[$i]);
     $age[] = mysql_real_escape_string($age_array[$i]);                    
  }
  mysql_query("UPDATE member SET name = '$name', age = '$age' WHERE id = '$id'");
  }
  ...
  ?&gt;
  </code></pre>
  
  <p>Can you help me? Thank you.</p>