我是displaying一张桌子,桌子的每一行都有approve和拒绝button,单击批准后的状态应该为reflect to database as approved。我尝试过,但是单击任何行的批准按钮后,它将被设置status为所有行的批准状态。我的PHP代码是:$doc_re = "select * from files where receiver='$user'";$record = mysqli_query($conn,$doc_re);if($record){ echo " <br><center><span class='badge badge-light' style='font-size:30px; background-color:teal;color:white;padding:10px;'>RECEIVED RECORDS</span></center>"; echo "<br><table class='table' border='3' style='background-color:rgba(2,2,2,0.7);'>"; echo "<thead class='thead-dark' >"; echo "<tr style='font-size:23px;'><th style='color:skyblue;'><center>TO</center></th> <th style='color:skyblue;'><center>FROM</center></th> <th style='color:skyblue;'><center>FILE</center></th> <th style='color:skyblue;'><center>MESSAGE</center></th> <th style='color:skyblue;'><center>APPROVE</center></th> <th style='color:skyblue;'><center>REJECT</center></th> <th style='color:skyblue;'><center>STATUS</center></th></tr></thead>"; while($r = mysqli_fetch_array($record,MYSQLI_ASSOC)) { echo "<tr><td style='color:white; font-size:18px;'><center><strong>{$r['receiver']}</strong></center></td> <td style='color:white; font-size:18px;'><center><strong>{$r['sender']}</strong></center></td> <td style='color:white; font-size:18px;'><center><strong><a href='".$r['file']."'>{$r['file']}</a></strong></center></td> <td style='color:white; font-size:18px;'><center><strong>{$r['message']}</strong></center></td> <form method='POST'> <td><center>将所有行的状态设置为已批准
2 回答
一只萌萌小番薯
TA贡献1795条经验 获得超7个赞
我认为您的查询有问题。它没有针对数据库表文件中的正确值。应该是这样的:
if(isset($_POST['approve']))
$q = "update files set Status='APPROVED' where receiver='{$r['receiver']}' and sender='{$r['sender']}' and file='{$r['file']}'";
elseif(isset($_POST['reject']))
$q = "update files set Status='REJECTED' where receiver='{$r['receiver']}' and sender='{$r['sender']}' and file='{$r['file']}'";
$res = mysqli_query($conn,$q);
- 2 回答
- 0 关注
- 117 浏览
添加回答
举报
0/150
提交
取消