Hi all,
I can't seem to get the script below to do multiple updates.
If there are two or more occurances of $new_expiry_date < $new_current_date then the below script only does the first $catid.
How can i get it to do all at once?
Cheers,
micmac
<?
$current_date = date("Ymd"); //now
$new_current_date = strtotime($current_date); //now-UNIX
echo "$new_current_date<br><br>";
$db = mysql_connect("localhost", "", "");
mysql_select_db("rod",$db);
$result = mysql_query("SELECT * FROM pref WHERE expiry_date != ''",$db);
while ($row = mysql_fetch_array($result)) {
$catid = $row["CatID"];
$expiry_date = $row['expiry_date'];
$new_expiry_date = strtotime($expiry_date);
if($new_expiry_date < $new_current_date){
$sql = "UPDATE cat1 SET pref='N' WHERE CatID=$catid";
$sql1 = "UPDATE pref SET listing_position='',expiry_date='' WHERE CatID=$catid";
$result = mysql_query($sql);
$result1 = mysql_query($sql1);
if($result || $result1){
echo "<br>Information updated.\n";
} else {
echo "<br><font color=\"red\"><b>ERROR:</b> Your data could not be updated</font>\n";
}
}
}
?>