PHP Code:
$banner = $db->query_first("SELECT userid, title, ext, width, height FROM " . TABLE_PREFIX . "banners WHERE status = 'active' AND available >= 1 ORDER BY RAND() LIMIT 1");
if(ctype_digit($banner['userid'])) {
//show it
} else {
//show default
}
The above code works fine and prints out code when the user's status is active and their available impressions is at least 1. I want to modify it to also check if the user has posted within the past 24 hours. I don't know how to though as I am using my own table in the vbulletin database to store the banner information. As you see above the query that fetches the data I need is querying from the table banners. From my knowledge I would need to fetch the last post time from lastpostdate in the user table. But how would I add this to my query so all three of these are factored in when it gets the one random array ($banner[]) from the banner table?
PHP Code:
$this->registry->db->query_write("UPDATE " . TABLE_PREFIX . "banners SET available = available + 100 WHERE userid = " . $this->registry->userinfo['userid']);
This query is the one that gives users impressions upon new post. I would like to change it so that it gives a different amount of impressions according to whether it's a new post or a new thread. How would I go about doing this?