我正在更新两列,即visastatus和当前日期。当我只更新我的visastatus列,然后它工作正常,但是当我应用此查询,其中两列正在更新,然后它使我的visastatus 0和当前日期也不更新。我的查询有问题吗?使用今天的日期更新列currentdate
<?php if(isset($_POST['submit']))
{
echo $radio = $_POST['radio'];
$date_clicked = date('Y-m-d');
$sql = "UPDATE user SET visastatus='$radio' and
currentdate='$date_clicked' WHERE id='$id'"; //this my update query.
$query = mysqli_query($conn, $sql);
if($query)
{
echo "<h4 style='color:green'>Action Performed Successfully....
</h4>";
}
else
{
echo "<h4 style='color:red'>Failed.</h4>";
}
}
?>
<form method="POST" action="" enctype="multipart/form-data">
<div class="col-xs-12 col-sm-6 col-md-6 col-lg-6" style="margin-top:
8px;" align="left">
<label class="checkbox-inline tourist-rad">
<input type="radio" name="radio" id="success" value="Successfull
done">Successfull
</label>
<label class="checkbox-inline tourist-rad">
<input type="radio" name="radio" id="decline" value="Visa
declined">Declined
</label>
</div>
<div class="form-group">
<button type="submit" name="submit" value="submit" class="btn
btn-primary" style="float: right;">Update Menu Item</button>
</div><br><br><br><br><br><br>
</body>
</html>
@AnkitKumar
使用
,
代替AND
这就是为什么我们更喜欢硬事实信念 – Strawberry首先你DB连接应该使用[PDO](http://php.net/manual/en/book.pdo.php)。 –
此查询不起作用。 @AnkitKumar – prak24