我有一个过滤测距日期的查询,我得到的结果很好。但在查询之后,我对如何更新我想要更改的表行感到迷失。
它就是这样的
<?php
if (isset($_POST['show'])){
if (isset($_POST['startDate']))
$startDate = strtoupper(trim(preg_replace("/[^0-9-]/", "", $_POST['startDate'])));// filter everything but spaces, numbers, and letters
if (isset($_POST['dateEnd']))
$dateEnd = strtoupper(trim(preg_replace("/[^0-9-]/", "", $_POST['dateEnd'])));// filter everything but spaces, numbers, and letters
$sql = mysql_query("SELECT * FROM enroll WHERE date >= '$startDate' AND date <= '$dateEnd' AND status = '0' ");
$DisplayList ="";
$enrollList = mysql_num_rows($sql);
if ($enrollList > 0) {
while($row = mysql_fetch_array($sql)){
$status = $row['status'];
$amount = $row['en_amount'];
if ($status == 0)
$st = 'NOT ENROLLED';
else
$st = 'ENROLLED';
$DisplayList .= "<strong>$st</strong><br />";//output the list request
}
} else {
$DisplayList = "PLEASE INPUT VALID ENTRIES";
}
}
?>
显示一个对我来说没问题的列表。过滤器是(我认为)好我没有问题。我想问的是,从上一个查询中我如何更新状态。我有这个'更新'按钮,如果单击该按钮,我想从上一个查询的范围输出更新行'status'。我希望我已经解释得很好。先感谢您。
答案 0 :(得分:0)
喜欢 Fred -ii - 说 - 使用UPDATE查询:
$status = 1;
mysql_query("UPDATE enroll SET status = '$status' WHERE date >= '$startDate' AND date <= '$dateEnd' AND status = '0' ");