title: Error in update arraylist in mysql database using php
body: <p>i am sending the arraylist from android to php. i want replace old menunames as new menunames. in my table contains two columns 1.menuimage 2.menuname.. i want to update only new menunames</p>
  
  <p>my table structure</p>
  
  <pre><code>                  test(table name)
             menucode     menuimage   menuname
               1            image       p
               2              "         q
               3              "          r
               4              "          s
               5              "           t
  </code></pre>
  
  <p>i want update only menuname according to the menucode ... i am passing menucode[1,2,3,4,5,6,7]...</p>
  
  <pre><code>&lt;?php
  
     $old_menu_code = explode(",", str_replace(array("[","]"), "", $_POST['menucode']));
     $new_menu_names = explode(",", str_replace(array("[","]"), "", $_POST['editmainmenu']));
    mysql_connect("localhost", "root", "root");
    mysql_select_db("test");
    foreach ($old_menu_names as $key =&gt; $old_name) {
    $new_name = mysql_real_escape_string($new_menu_names[$key]);
    $old_code = mysql_real_escape_string($old_menu_code[$key]);
  
    mysql_query("UPDATE `test` SET `menuname` = '$new_name' WHERE menucode= '$old_code'") or die('Error' . mysql_error());
  echo "Updated";
     }
    ?&gt;
  </code></pre>
  
  <p>the above code  test is database contains test table.in test table contains two columns one menuimage and menuname . in menuimage contains 7 images and menuname contains 7 menunmaes. i want only update menuinames. but above code update only first row menunames column. remaining rows are not updated..please what mistake i have been done</p>