write sql to expire records on a results page using dataassist search
want items to expire 60 days after posting
here is the Recordset that i have
SELECT *,DATE_FORMAT(items.item_listed, '%b %e, %Y') AS theDate
FROM items INNER JOIN accounts ON items.account_ID = accounts.account_ID
WHERE items.category_ID = var1 AND items.item_listed>= CURDATE() - INTERVAL 60 DAY
ORDER BY items.item_listed DESC
Using dataassist search
code is
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$currentPage = $_SERVER["PHP_SELF"];
$maxRows_rs_itemcat = 10;
$pageNum_rs_itemcat = 0;
if (isset($_GET['pageNum_rs_itemcat'])) {
$pageNum_rs_itemcat = $_GET['pageNum_rs_itemcat'];
}
$startRow_rs_itemcat = $pageNum_rs_itemcat * $maxRows_rs_itemcat;
$var1_rs_itemcat = "-1";
if (isset($_GET['item_cat_ID'])) {
$var1_rs_itemcat = (get_magic_quotes_gpc()) ? $_GET['item_cat_ID'] : addslashes($_GET['item_cat_ID']);
}
mysql_select_db($database_connbubba, $connbubba);
$query_rs_itemcat = sprintf("SELECT *,DATE_FORMAT(items.item_listed, '%%b %%e, %%Y') AS theDate FROM items INNER JOIN accounts ON items.account_ID = accounts.account_ID WHERE items.category_ID = %s AND items.item_listed>= CURDATE() - INTERVAL 60 DAY ORDER BY items.item_listed DESC", GetSQLValueString($var1_rs_itemcat, "int"));
setQueryBuilderSource($query_rs_itemcat,$WADbSearch1,false);
$query_limit_rs_itemcat = sprintf("%s LIMIT %d, %d", $query_rs_itemcat, $startRow_rs_itemcat, $maxRows_rs_itemcat);
$rs_itemcat = mysql_query($query_limit_rs_itemcat, $connbubba) or die(mysql_error());
$row_rs_itemcat = mysql_fetch_assoc($rs_itemcat);
if (isset($_GET['totalRows_rs_itemcat'])) {
$totalRows_rs_itemcat = $_GET['totalRows_rs_itemcat'];
} else {
$all_rs_itemcat = mysql_query($query_rs_itemcat);
$totalRows_rs_itemcat = mysql_num_rows($all_rs_itemcat);
}
$totalPages_rs_itemcat = ceil($totalRows_rs_itemcat/$maxRows_rs_itemcat)-1;
$queryString_rs_itemcat = "";
if (!empty($_SERVER['QUERY_STRING'])) {
$params = explode("&", $_SERVER['QUERY_STRING']);
$newParams = array();
foreach ($params as $param) {
if (stristr($param, "pageNum_rs_itemcat") == false &&
stristr($param, "totalRows_rs_itemcat") == false) {
array_push($newParams, $param);
}
}
if (count($newParams) != 0) {
$queryString_rs_itemcat = "&" . htmlentities(implode("&", $newParams));
}
}
$queryString_rs_itemcat = sprintf("&totalRows_rs_itemcat=%d%s", $totalRows_rs_itemcat, $queryString_rs_itemcat);
?>
i have tested and no matter the if the INTERVAL is only 1 day, the item still shows up
thanks for your help,
jim balthrop