I am making a simple friends feature for my site and when people get a friend request I want it to show on there friends panel link so I tried this.
$q = $dbc -> prepare("SELECT id_to read FROM friend_requests WHERE id = ? && read == '0'");
$q -> execute(array($details['id']));
$request_count = $q -> rowCount();
if ($request_count > 0) {
echo '<li><a href="/friends"><img src="/gameimages/friends.png" height="16" width="16" alt="" /><strong>Friends (' . $request_count . ')</strong></a></li>';
}
else {
echo $request_count;
echo '<li><a href="/friends"><img src="/gameimages/friends.png" height="16" width="16" alt="" />Friends </a></li>';
}
Now on the friends page where requests are shown all requests get the column of read set to 1, and by default it is 0. If there are rows with 0 it shall be a new request and the query above should fire letting users know that they have new requests, what am I doing wrong?