我正在使用url .if从android向php传递两个数组列表,表(.if)只包含一列(Menuname),表示正确更新。如果我正在向table(test)添加另一列,就像menuimage一样,意味着列(Menuname)第一行被更新,其他行没有正确更新。
<?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";
}
?>如果具有两列的表意味着第一行仅更新了剩余行,则不会更新。
发布于 2012-04-11 19:50:40
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.https://stackoverflow.com/questions/10104424
复制相似问题