我正在尝试从数据库中删除行。 DELETE
查询正在检查数组中日期的匹配,并且reason
为空。我的代码是;
<?php
session_start();
include 'connection.php';
include 'DateTest.php';
$deleted = array();
$size = sizeof($dayOfTheWeek) - 1;
for ($count = 0; $count <= $size; $count++) {
$query = "DELETE FROM daysoff WHERE DATE(start) = '$dateMonthYearArr[$count]' AND reason = ''";
mysql_query($query) or die("im dead1");
$deleted[] = "Rota deleted for ". $dateMonthYearArr[$count] .".</br>";
} $_SESSION['delete'] = $deleted;
header('Location: '. $_SERVER['HTTP_REFERER']) ;
?>
这个DELETE
查询正在消亡,如果我删除其中一个WHERE
个参数,任何一个,它都有效,但AND
似乎是一个问题。这在哪里失败了?
答案 0 :(得分:0)
尝试
$query = "DELETE FROM daysoff WHERE DATE(start) = '" . $dateMonthYearArr[$count] . "' AND reason = ''";
看看它是怎么回事......