View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

write sql to expire records on a results page using dataassist search

Thread began 10/29/2009 6:45 pm by JBWebWorks | Last modified 10/30/2009 5:06 pm by JBWebWorks | 1349 views | 3 replies

JBWebWorks

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

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...