but I already got a way around it. Let me just share may be it might help someone:
Every alert ought to direct the user to a certain URL e.g. if someone commented on your post, on clicking the alert you should be directed to e.g. "www.example.com/posts/?post_id=5". I cal this the target URL. when generating the alert, i store its target URL together with the alert details in the alerts table, and get the AI unique field(alert_id), which i will use to generate the href part of any link on the alert eg <a href="changetoread.php?alert_id=56">G Thuo</a>
commented on your post.
this is my approach: on clicking any alert, it first takes you somewhere where its status is changed to read(basing on the alert_id in the link). After it's changed to read, then we fetch the target URL from the table and redirect the user there. here's my code:
$alert_id=$_GET['alert_id'];
$user_id=$_SESSION['user_id'];
//create the SQL to update the read_status
$sql="UPDATE alerts_log SET read_status=1 WHERE alert_id=$alert_id AND user_id=$user_id";
$res=mysql_query($sql) or die(mysql_error());
//we can now extract the targer_url from the alerts table and redirect the user automatically to that URL
$sql="SELECT target_url FROM alerts WHERE alert_id=$alert_id";
$res=mysql_query($sql) or die(mysql_error());
$row=mysql_fetch_assoc($res);
$url=$row['target_url'];
//redirect the user to that URL
header("Location: $url");
`