Hi,
I've gote this problem to resolve. I have to do a list of products that a seller have for sale. The seller need to renew the date of his products every 14 days (RENEW_DELAY) if he wants his products be shown on the website. For this reason I need to display the products that have been:
renewed (active),
soon to expire (within 5 days=EXPIRED_SOON)
recently expired(within the last 30 days=EXPIRED_WITHIN)
All products(active and inactive)
This is a query that I formulate but I'm not quiet sure it is correcte:
$s2 = "SELECT b.Name AS Brand, c.Name AS category, CategoryID, p.ID, p.Price, p.DeliveryPrice, p.Name, p.Reference, p.Description,
p.Image, (TO_DAYS(NOW()) - TO_DAYS(RenewDate)) as delay, RenewDate
FROM Products AS p LEFT JOIN Brands as b ON b.ID=p.BrandID
LEFT JOIN Categories AS c ON c.ID = p.CategoryID WHERE p.Purchased =\"No\" AND p.SellerID=$seller_ID ";
if($vars["status"]=="active"){
$s2 .= "AND (TO_DAYS(NOW()) - TO_DAYS(RenewDate) < ".RENEW_DELAY." )";
}elseif($vars["status"]=="soon to expired"){
$s2 .= "AND ".RENEW_DELAY." > (TO_DAYS(NOW()) - TO_DAYS(RenewDate) > ".((int)RENEW_DELAY-EXPIRED_SOON)." )";
}elseif($vars["status"]=="recently expired"){
$s2 .= "AND ".RENEW_DELAY." > (TO_DAYS(NOW()) - TO_DAYS(RenewDate) > ".((int)RENEW_DELAY+EXPIRED_WITHIN)." )";
}else{
$s2;
Please can anyone help me !!!! }