0
我想根據條件從數據庫中刪除某個項目。以下是我有:從mysql數據庫中的表中刪除行
while ($row = mysql_fetch_array($result)) {
$now = strtotime("now");
$dateArray = date_parse_from_format("n-j-Y", $row["date"]);
$event_date = strtotime($dateArray['year'].'-'.$dateArray['month'].'-'.$dateArray['day']);
// temp user array
$event = array();
if($event_date > $now) {
//Event is in the future
$pid_check =$row["pid"];
$event["pid"] = $row["pid"];
$event["name"] = $row["name"];
$event["longitude"] = $row["longitude"];
$event["latitude"] = $row["latitude"];
$event["pavement"] = $row["pavement"];
$event["traffic"] = $row["traffic"];
$event["environment"] = $row["environment"];
$event["image_b64"] = $row["image_b64"];
$event["date"] = $row["date"];
$event["time"] = $row["time"];
$event["type"] = $row["type"];
// push single product into final response array
array_push($response["events"], $event);
} else {
$result2 = mysql_query("DELETE FROM events WHERE pid = $pid_check");
}
}
但是當我嘗試這一點,出現空白,當我註釋掉RESULT2它的工作原理,但不會刪除(杜)。我怎樣才能讓它刪除?對不起,如果這是一個簡單的問題,我對這門語言的瞭解並不多。
...謝謝你,我應該注意到:(。 – TylerM