I'm trying to detect if the data in the db is expired or not, and it works prefectly fine as long as I only have on data to check when there are mutiple data needed to be check then everything will somehow follow the first one's behavior
while($row=mysqli_fetch_assoc($exe))
{
date_default_timezone_set("Asia/Taipei");
echo $row['ExpeTime']." ";
echo $ExpTim=strtotime($row['ExpeTime']);
echo " ";
echo $TWnowSec=date("U");
echo " ";
/*if($ExpTim>$TWnowSec){
echo "沒過期";
}elseif($ExpTim<$TWnowSec){
echo "過期了";
}*/
if($ExpTim<$TWnowSec) {
$sql= "UPDATE productneeds SET Status='已過期';";
if(!mysqli_stmt_prepare($stmt, $sql)){
echo "update failed";
}else{
mysqli_stmt_execute($stmt);
echo "sucess";
}
}else {
echo "{$row['O_no']} is not expired<br>";
}
}
$stmtto prepare call whose first argument should be connection object,$conn. Then you execute the query using$stmt.