Hmmm. That didn’t do the trick either… Maybe it has something to do with my pagination script.
Here is my pagination script query:
[php]<?php
$adjacents = 2;
$classifieds = DB::getInstance()->query("SELECT id
, dates
, username
, title
, description
FROM knollsclassifieds
");
$records = $classifieds->Count();
$targetpage = basename($_SERVER[‘PHP_SELF’]);
$limit = 2;
$page = isset($_GET[‘page’])? $_GET[‘page’] : 1;
if ($page)
$start = ($page - 1) * $limit;
else
$start = 0;
$classifieds = DB::getInstance()->query(“SELECT * FROM knollsclassifieds
ORDER BY id DESC LIMIT $start, $limit”);
if ($page == 0)
$page = 1;…
[/php]
Then here is the classifieds.php page and how its structured:
[php]<?php include_once($_SERVER['DOCUMENT_ROOT'] . "/functions/pagination-classifieds.php"); ?>
<?php $classifieds = DB::getInstance()->query("DELETE FROM `knollsclassifieds` WHERE `dates` > DATE_ADD(`dates`, INTERVAL 10 MINUTE)"); ?>
<?php foreach($classifieds->results() as $c){ ?>
<?php echo escape($c->title); ?>
<?php echo escape (date("M. d, Y", strtotime ($c->dates))); ?> - Posted by: <?php echo escape($c->username); ?>
.articletext img{width:100%; height:auto;}<?php echo ($c->description);?>
<?php
}
?>
[/php]
It doesn’t matter where this query is placed on the page does it?
[php]<?php $classifieds = DB::getInstance()->query("DELETE FROM `knollsclassifieds` WHERE `dates` > DATE_ADD(`dates`, INTERVAL 10 MINUTE)"); ?>[/php]
I guess if this doesn’t work another way to go would be to only display classified ads under 30 days old. Then on my admin section I could display all ads over 30 days old and delete them manually. Not sure how to write that in the query though…? I will do some research on that.
I appreciate your help. Let me know if you have any ideas.