Great hack.. it was an improvement over what I was doing already because it has the multiple pm option. One problem though, the query as posted runs very slow on my site (166k PMs stored). I've never understood the duplicate fields in the PM table, but changing around the WHERE clause helps alot:
PHP Code:
SELECT p.privatemessageid AS pm_popup_id, p.title AS pm_popup_title,
u.username AS pm_popup_username FROM privatemessage p, user u
WHERE messageread = 0 AND p.userid = $bbuserinfo[userid] AND
p.fromuserid = u.userid ORDER BY dateline DESC
That uses the indexed p.userid field instead of the unindexed p.touserid. It seems to work the same and is no longer a PITA query. Thanks for the hack.