代码:
<?php
if(isset($_POST['save']))
{
$comment1 = $_POST['comment2'].",".date('Y-m-d');
$comment2 = $_POST['comment2'];
$date = date('Y-m-d');
$chk = implode(",", $_POST['chk']);
$id = explode(",", $chk);
foreach ($id as $id)
{
echo "update enquires2 set comment1='$comment1' , comment2='$comment2' , s_date='$date' where id='$id'";
}
}
?>
<form name="myform" method="POST">
<table>
<tr>
<th>History</th>
<th>Add Comment</th>
<th>Action</th>
</tr>
<?php
$sql = "select * from enquires2";
$result = mysqli_query($link,$sql);
while ($row = mysqli_fetch_array($result))
{
echo "<tr>
<td><input type='checkbox' name='chk[]' value=".$row['id']."></td>
<td>".$row['comment1']."</td>
<td>
<input type='text' name='comment2' id='comment2' />
</td>
</tr>";
}
echo "<tr>
<td>
<input type='submit' name='save' value='save'>
</td>
</tr>";
?>
</table>
</form>
在此代码中,当我在comment2中插入值时,选中复选框并单击“保存”按钮,然后打印查询,如图所示。它没有发表评论2的价值。我该如何解决这个问题?请帮忙。
谢谢