更新查询无效。此查询无效。
我尝试打印变量,所有变量都包含值
我该如何解决这个问题?
表单代码:
echo"<td data-title='Status'>";
if ($percent == 0) {
echo"<form class='form-inline' role='form' action='";
?><?php $_PHP_SELF ?><?php
echo"' method='post' accept-charset='UTF-8'>
<select id='' name='status' class='form-control input-md'>
<option valur='.$status.'>$status</option>
<option value='Pending'>Pending</option>
<option value='Cancel'>Cancel</option>
</select>";
echo"</td>";
echo"<input type='hidden' name='txt_id' value='.$id.'>";
echo"<td>";
echo"<input type='submit' name='update' class='btn btn-default' value='Update' />";
}
else if ($percent >= 1 && $percent < 100) {
echo"Running";
}
else if ($percent == 100) {
echo"Done";
}
echo"</td>";
echo"</form>";
更新代码:
if (isset($_POST['update'])) {
$status = $_POST['status'];
$ids = $_POST['txt_id'];
$sql = mysqli_query($conn, "UPDATE tbl_project SET db_status='$status' WHERE db_id='$ids'")or die(mysqli_error($conn));
}
答案 0 :(得分:0)
1)
首先尝试删除value='.$id.'
它应该是
echo"<input type='hidden' name='txt_id' value='$id'>"
如果你的$id = 1
;然后value = '.$id.'
等于value = '.1.'
;
第一个选项值
也是如此<option valur='.$status.'>$status</option> // this is wrong
使用此
<option value='$status'>$status</option>
2)在运行之前,第二次尝试echo
query
if(isset($_POST['update'])){
$status=$_POST['status'];
$ids=$_POST['txt_id'];
// echo "UPDATE tbl_project SET db_status='$status' WHERE db_id='$ids'";die; just to debug
$sql=mysqli_query($conn,"UPDATE tbl_project SET db_status='$status' WHERE db_id='$ids'") or die(mysqli_error($conn));
}
,以便回复您的查询
SELECT * FROM tbl_courier WHERE FIND_IN_SET(cons_no,'1,2,3,4,5')