PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
This is a bit from a code I have been using for a certain website for about a month now. It has been working fine until today I noticed it displayed the else statement for articles that where edited today (September 10th, 2007). I've been playing around with it trying to fix this, and haven't had any success - but I can simply cannot understand why it is doing this. I alos noticed it will repeat this for tomorrow and the day after. Any thoughts? THANKS!
$query = "SELECT *, DATE_FORMAT(last_edit, '%M %D, %Y') as last_edit FROM database WHERE `page_name` like '$page_name' AND `side` LIKE 'l' AND `position` > 0 ORDER BY `position`";
if ($last_edit > date("F jS, Y", strtotime ("-8 days"))) echo "
Updated $last_edit
"; else echo "
$last_edit
";
SELECT
*,
DATE_FORMAT(last_edit, '%M %D, %Y') as formatted_last_edit,
IF(`last_edit` > DATE_SUB(CURDATE(),INTERVAL 8 DAY), 1, 0) as edited_in_last8days
FROM `database`
WHERE `page_name` like '$page_name' AND `side` LIKE 'l' AND `position` > 0
ORDER BY `position`";
PS: Database is a keyword - maybe this is your problem with this query... Try to use mysql_error
There are 10 types of people in this world, those who understand binary and those who don't
SELECT
*,
DATE_FORMAT(last_edit, '%M %D, %Y') as formatted_last_edit,
IF(`last_edit` > DATE_SUB(CURDATE(),INTERVAL 8 DAY), 1, 0) as edited_in_last8days
FROM `database`
WHERE `page_name` like '$page_name' AND `side` LIKE 'l' AND `position` > 0
ORDER BY `position`";
PS: Database is a keyword - maybe this is your problem with this query... Try to use mysql_error
Thanks - actually I just used "database" rather than the actual db name to make it more clear.
I think your way is excellent. Here's how I just ended up going about it for any out there curious: