Is there any way I can test this?
I'll admit to being a bit lacking in knowledge in regards to how much stress/load things have on the database but if I have it checking for PMs for the user every time they load a new page is that going to cause more strain than necessary on the database/server or is the effect going to be minimal and is there a better way to do it?
At the moment it's just a case of it querying the database with the code below on each page the user loads and if there's an unread message/s for that user it will add echo the number.
$db = mysql_connect($dbhost,$dbuser,$dbpass);
mysql_select_db($dbname,$db);
$result = mysql_query("SELECT COUNT(*) as newpms FROM private_messages WHERE to_id = '{$userid}' AND viewed = 'N'",$db);
$record = @mysql_fetch_array($result);
if($record[newpms] != 0)
echo '<b>('.$record[newpms].')</b>';
mysql_close($db) or die("Error: ".mysql_error());
Thanks