Hehe!
Good to see you, Mr Packet.
I gave a condensed version of my setup so that it wouldn't interfere with me showing off what an idiot I am. Now that you're all thoroughly impressed I'll continue.
There are actually about 8 different message types that would trigger an alert. Each type has its own table in the db such as pms, inv, etc... (Don't kill me but they are actually named like that)
I also have a small table called new_msgs that contains user_id, 8 corresponding fields for the different notifier types, and a field called "has_new_msgs". When a member receives a message; the proper field in the new_msgs table gets a ++ and the "has_new_msgs" field is set to one. I did this so that I could quickly query a single field to see if the member has msgs or not, and if so; follow-up with the full-blown extraction. I know this adds an extra query when the member does have new msgs, but I figured that it was a good trade-off since 90% of the time they won't; and the script needn't have to constantly loop through functions to know that.
Iffins the member has new msgs I query the entire new_msgs table:
SELECT chat, inv, frm,...FROM new_msgs..
and then reference this array from my functions include:
$f_msg_array = array(chat => "Chat Invitation", inv => "FriendInvite", frm => "FriendMail",...");
to do:
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
$i=0;
$arraynum=0;
foreach ($row as $col_value) {
if($col_value > 0){
$arraynum++;
$field=mysql_field_name($result,$i);
$field_txt=$f_msg_array[$field];
$output_array[$arraynum] = "$col_value new $field_txt";
}
$i++;
}
}
return $output_array;
...which gives the result as a few simple sentences to pass on to the Flash file in the header. Critique plenty welcome!
OK,..back to me sessions,..
"The problem with not querying the PM database to see if there are new PMs is: how is the page supposed to know if there are new PMs without querying?"
Here's where I'm lost. Isn't there a way for me to set site-wide variables in an array that are accesible to all visitors? For example; would it be possible to store CSS info in a global session array, and then when somebody clicked the green button it updated the $sitewide_array's "row_color" value to green, and members would see the change on the next refresh? Is the server actually capable of lugging around info like that or is it entirely on the user's end? If it is possible; couldn't I apply the same logic to update an array of userid's with new_msgs? I know that it wouldn't target a page that the member is on, but I could check to see if Steve's userid is in the global $users_with_new_msgs_array on pageloads. If it is; Steve's $_SESSION['has_new_msgs'] var gets set to one and his value removed from the array until the next message he receives. 😕
Sorry, I've been thinking about it too long. Thanks for jumping in WP. 🙂