Code:
if ($table=="privatercvd") {
$messages = $DB_site->query("SELECT msgid,toid,fromid,title,UNIX_TIMESTAMP(datetime) AS datetime,iconid,repliedto FROM $table WH
} elseif ($table=="privatesent") {
$messages = $DB_site->query("SELECT msgid,toid,fromid,title,UNIX_TIMESTAMP(datetime) AS datetime,iconid FROM $table WHERE fromid
}
if ($messages) {
//parse each message
while ($message=$DB_site->fetch_array($messages)) {
$fromid = trim($message[fromid]);
if ($ignore[$fromid]) {
continue;
}
$fromuser = $DB_site->query_first("SELECT username FROM user WHERE userid=$fromid");
$from = stripslashes(trim($fromuser[username]));
$toid = trim($message[toid]);
$touser = $DB_site->query_first("SELECT username FROM user WHERE userid=$toid");
if ($table=="privatesent") {
$from = trim($touser[username]);
I have just read through the code briefly... and have a few suggestions:
1) The part where we want to get the name of $fromuser is a new query, so the number of queries fired will be proportional to the number of PM a person gets, why not do a join ?
2) the second part, to find the $touser, afaik, this field is useful if we are at the SentItems folder? So if we are else where, those queries fired are just wasting CPU cycles?
just my 2 cents..