根据以前的查询php / mysql在列的多行上设置值

时间:2017-02-02 16:52:55

标签: php mysql

运行以下查询($ box是上一页的是或否):

$raw_results = mysqli_query($con,"
SELECT * 
  FROM `tbl_case` 
 WHERE `self_paid` ='$box' 
   AND `case_date_closed` BETWEEN '$startdate' AND '$enddate'  
");

它正确显示所有字段,并以另一个复选框结束 使用下面的单选按钮,如果选择是,则应在所有先前返回的$ id'上设置yes给paid_state

<h1>    Would you like to set these as paid to self ?
    <form>
    <form action="selfpaid.php" method="POST">
 <input type="radio" name="state" value="yes" checked> Yes<br>
 <input type="radio" name="state" value="no"> no<br>
<input type="submit" style="margin-left:80px; width:150px; height:30px;" value="Set state" />
 </form>
<?php
if(isset($_POST['state']) && $_POST['state'] == "yes")
{
 mysqli_query($con,"UPDATE tbl_case SET self_paid = 'yes' WHERE id =     '$id'");
   echo "Setting paid statesucessfull.";
 }
else{
echo "paid_state not set";
}
?>

我猜它需要从数据库中提取,并将所有那些$ id放在另一个数组var中,但我可以;弄清楚如何,然后循环遍历那个数组..有人能指出我在右边方向?

0 个答案:

没有答案