所以,我来到这个代码(有效):
public class Post {
String post;
String liked;
public void setIvLike(View view){
if(view.isActivated())
view.setActivated(false);
else
view.setActivated(true);
}
public String getPost() {
return post;
}
public void setPost(String post) {
this.post= post;
}
public String getLiked() {
return liked;
}
public void setLiked(String liked) {
this.liked = liked;
}
}
现在,我的问题是我有3个数组,我想用它们保存的值更新数据库表列。下面是我的数组的一个例子:
$values = Array (
Array ( 'entry_id' => 41142, 'test2' => 124, 'lev' => 'Jah'),
Array ( 'entry_id' => 41103, 'test2' => 1286634, 'lev' => 'Jaja'),
Array ( 'entry_id' => 41100, 'test2' => 1234, 'lev' => 'Ja')
);
foreach ($values as $key)
{
$sql_update = mysql_query("UPDATE arr set test2 ={$key['test2']},lev ='{$key['lev']}' where entry_id = '{$key['entry_id']}'");
}
这是我的桌子 database table
以下是我希望在更新后的表格中显示的记录。 databasetable after update 这是我的更新代码
$apid=array(1,2,3,4);
$act=array(303,304,305,306);
$reason=array('delivery','contract','cargo','offloading');
下面是我得到的错误:
//getting values from form
$apid = $_POST["relate"];
act = $_POST["act"];
$reason = $_POST['reason'];
$values=array('reas'=>$reason,'actu'=>$act,'ids'=>$apid);
//the below code is us suggested, by one of the users, on my earlier post
$update_row =mysql_query("UPDATE ActivityProduct SET Actual= '{$values['actu']}',Reason='{$values['reas']}' WHERE APID='{$values['ids']}' ");
第66行是带有更新声明的那一行。
我讨厌承认,但我被困在这里。请帮忙!