PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
$uid = $_SESSION['userID'];
$query = "SELECT userID FROM posts WHERE userID='$uid'";
$result = @mysql_query($query) or die(mysql_error());
if (mysql_fetch_assoc($result))
{
echo '<a href=reportedit.php class=under>EDIT</a>';
}
else
{
NULL;
}
i am comparing the userID of the post with the session key...if they match, the edit link will appear....but this is not happening....the edit link appears even if it is not thread or post....any help from you guys will be greatly appreciated...
thinking about it, you code will always return true because as long as the current user has made a post, the edit link will appear on ALL posts, regardless whether it is their post ot not
Are you comparing the userid of the session with a specific post, as in going through each post individually and checking....if so you'd need to check the posts userID against the $_SESSION userID and filter only the current post your checking. All the code you have is doing is checking if the user has any posts, and if they do, displays a link.
Try this:
Did you just cut and paste? I wasn't providing cut+paste code, just showing you that the query you originally had gets all posts from a specific user. You probably need to add more restrictions to the query.