0

我使用url将两个arraylist从android传递给php。如果表(测试)只包含一列(菜单名)意味着正确更新。如果我要向表(测试)添加另一列,就像 menuimage 意味着在第一行列(菜单名称)被更新,其他行没有正确更新。

<?php
    $old_menu_names=explode(',',preg_replace('/^.*\[(.*)\].*$/','$1',trim($_POST['menuname'], '[]')));
    $new_menu_names=explode(',',preg_replace('/^.*\[(.*)\].*$/','$1',trim($_POST['editmainmenu'], '[]')));
    mysql_connect("localhost", "root", "MobixMySQL");
    mysql_select_db("cozydine");
    foreach ($old_menu_names as $key => $old_name) {
        $new_name = mysql_real_escape_string($new_menu_names[$key]);
        $old_name  = mysql_real_escape_string($old_menu_names[$key]);
        echo $new_name;
        mysql_query("UPDATE `mainmenu` SET `menuname` = '$new_name' WHERE menuname = '$old_name'")
        or die('Error' . mysql_error());
        echo "Updated";
    }
?>

如果具有两列的表意味着第一行仅更新剩余行不更新..

4

1 回答 1

0
In java you can send name value pair like this
 JSONObject object=new JSONObject();
 object.put("name","value");

 and import net.sf.json.JSONObject;

 and send the object.
 and in php version heigher than 5 you can get the values using json_decode() function

 json_decode($object);


 Hope this will help.
于 2012-04-11T11:50:40.493 回答