我的代碼沒有更新我的數據庫中的行,沒有語法錯誤,所以它必須是邏輯錯誤,它可能是大括號的位置。我想更新同一行中的多個列。下面是代碼 -PHP,更新多列時出錯
<table border="1" align = "center" >
<form method="POST" action="testupdate.php">
<?php
while ($row=mysqli_fetch_assoc($q)){
?> <tr><td><input name="select2" type="radio" value="<?php echo $row['c_id']; ?>"></td>
<?php
echo "<td>".$row['c_id']."</td>";
echo "<td>".$row['no_computer']."</td>";
echo "<td>".$row['c_type']."</td>";
echo "<td>".$row['c_location']."</td></tr>";
}
?>
<input type="submit" name="update" value="update" ></table></form>
<form method="POST" action="testupdate.php">
<?php
if (isset($_POST['select2'])){
if (isset($_POST['update'])){
?>
<form method="POST" action="testupdate.php">
no of computers: <br /><input type="text" name="no_computer2"><br /><br />
type: <br /><input type="text" name="c_type2"><br /><br />
location: <br/><input type="text" name="c_location2"><br /><br />
technical status: <br /><input type="text" name="tech_status2"><br /><br />
<input type="submit" name="ok" value="okay">
</form>
<?php
if (isset($_POST['ok'])){
$nc2= $_POST['no_computer2'];
$ct2= $_POST['c_type2'];
$cl2= $_POST['c_location2'];
$ts2= $_POST['tech_status2'];
$i=$_POST['select2'];
$s2="UPDATE `tech_computer` SET `no_computer`='$nc2' , `c_type`='$ct2' , `c_location`='$cl2', `tech_status`='$ts2' where `c_id` like '$i'";
$q2=mysqli_query($s2);
header ('location:testupdate.php');
}}}
?>
我看你沒看過[漫畫](https://xkcd.com/327/)! –