Php 如何在android环境下更新mysql数据库中的arraylist
我正在使用url将两个arraylist从android传递到php。如果tabletest只包含一个ColumnMenuame,则表示正确更新。如果我将另一列添加到tabletest中,就像menuimage一样,意味着在列的第一行MenuName被更新,其他行没有正确更新Php 如何在android环境下更新mysql数据库中的arraylist,php,mysql,arraylist,Php,Mysql,Arraylist,我正在使用url将两个arraylist从android传递到php。如果tabletest只包含一个ColumnMenuame,则表示正确更新。如果我将另一列添加到tabletest中,就像menuimage一样,意味着在列的第一行MenuName被更新,其他行没有正确更新 <?php $old_menu_names=explode(',',preg_replace('/^.*\[(.*)\].*$/','$1',trim($_POST['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";
}
?>
如果表有两列,则表示只更新第一行,而不更新其余行 为什么不将数组tp php作为json发送呢。我不知道如何在json中发送名称-值对。。这就是我发送数组列表的原因。若表格只有一列,则表示工作正常。若表有多个列,则表示只更新第一行。。
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.