Thanks Gary! I did some brain storming this evening, after a much needed break from coding (kinda sux sometimes when you have a large web dev team, and you're the only one that fully understands PHP, vb, MySQL, and how it ALL goes together)
Anyway, here's my VERY rough draft of the snippet of code that I *think* will work
It will require adding 2 new fields: displayweek and displayed. Display week will hold the INT of the week that member was/is displayed, and the displayed feild will be a -1,0,1 flag. 0 for not being displayed yet, 1 for being previously displayed, and -1 for being currently displayed.
Oh, and FYI, MOTW stands for Member of the week (just my little coding abbreviation
Feel free to pick it apart (aside from syntax... I know it's not right) conceptually and let me know what you all think:
PHP Code:
$currentweek = date(W);
$displayMOTW=$DB_site->query_first("SELECT * FROM memberphoto WHERE visible=1 AND displayweek=$currentweek AND displayed=-1");
// Check to see if there is an existing valid MOTW to be displayed
if ($displayMOTW) {
Display the Member of the week
} else {
//Set any 'old' MOTW to displayed status and pick new MOTW
//setting all expired MOTW to displayed status
$DB_site->query("UPDATE memberphoto SET displayed=1 WHERE displayed=-1 AND displayweek<>$currentweek");
//count the number of remaining candidates to select from
$candidates=$DB_site->query("SELECT COUNT(*) AS count FROM memberphoto WHERE visible=1 AND displayed=0");
//check to make sure there are candidates available, if not, reset everyone
if ($candidates[count] = 0) {
$DB_site->query("UPDATE memberphoto SET displayed=0");
}
$newMOTW = $DB_site->query("SELECT * FROM memberphoto WHERE displayed=0 ORDER BY RAND() LIMIT 1)";
$DB_site->query(UPDATE memberphoto SET displayed=-1, displayweek=$currentweek WHERE userid=$newMOTW['userid']");
Display the Member of the week
}