$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 the lastpostdate column 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 banners table?
As well I would like to setup the query to also not pick the row in the banners table that matches the vistor's userid (so users do not see their own banners being displayed).