I'm trying to change the query listed below. Right now, the query returns threads based on a single date. I want the query to accept a separate date for each forum, which I've already stored in another table.
I think the line that has to be changed is "AND thread.lastpost >=$datecut"
Instead of using the date in $datecut, I want to pull a separate date from another table called lastreads which contains the following fields:
lastreads_id, lr_member, lr_forum and lr_lastviewed. (key to fields: lastreads_id is an autoincrement index, lr_member contains a userid, lr_forum contains a forumid, and lastviewed contains the "timenow" that lr_member last read lr_forum.
I want to pull the value in lr_lastviewed where forumid = lr_forum and $bbsuserinfo('userid') = lr_member and plug that value into the query so that it uses the separate date that has been stored for each forum.
Original Query that I want to change:
Code:
$threads = $DB_site->query("
SELECT threadid
FROM " . TABLE_PREFIX . "thread AS thread
LEFT JOIN " . TABLE_PREFIX . "deletionlog AS delthread ON(delthread.primaryid = thread.threadid AND delthread.type = 'thread')
WHERE forumid IN(" . implode(', ', $forumids) . ")
AND thread.lastpost >= $datecut
AND visible = 1
AND delthread.primaryid IS NULL
AND sticky IN (0,1)
ORDER BY lastpost DESC
LIMIT $vboptions[maxresults]
");
Can someone help me revise this query so that it does what I want?
thanks,
Ed