嗨朋友请告诉我我哪里错了,即使更新查询执行成功,数据库仍然没有变化谢谢
这是表单代码
echo'<form action="processor.php" method="post" id ="post_form">';
echo '<input type="hidden" name= "status" id="status" value="">';
$upload_arr=array("1");
foreach($upload_arr as $upload_id)
{
echo '<input type="button" name="accept-<?=$upload_id?>" value="accept" onclick="submit_this(this.name)"/><br>';
echo '<input type="button" name="reject-<?=$upload_id?>" value="reject" onclick="submit_this(this.name)"/><br>';
echo '<input type="button" name="saccept-<?=$upload_id?>" value="saccept" onclick="submit_this(this.name)"/><br>';
echo '<input type="button" name="sreject-<?=$upload_id?>" value="sreject" onclick="submit_this(this.name)"/><br>';
}
echo '</form>';
注意:这里我使用了 $upload_id 一个 php 变量,它具有 row[upload id] 即它就像第一个图像的接受 1、reject1、saccept1 和 sreject1 和第二个图像它是 accept2 reject2 等等
现在是processor.php的代码
$status_pass = isset($_POST['status'])?$_POST['status']:NULL;
if(!empty($status_pass)){
$status_arr = explode('-', $status_pass);
$action = $status_arr[0];
$upload_id = $status_arr[1];
if($action == 'accept'){
$status = 1;
}
if($action == 'reject'){
$status = 2;
}
if($action == 'saccept'){
$status = 3;
}
if($action == 'sreject'){
$status = 4;
}
echo $status;
$sql="UPDATE upload SET status='$status' where upload_id = '$upload_id' ";
echo "update success";
$result = mysql_query("$sql") or die("Invalid query: " . mysql_error());
}