I am making a favourite option for a dating site.
I am trying to make the option 'delete' if you already have that fav or 'add' if you dont.
So I do a query based on the users id to see if they are a fav - problem is the code only works for some favs and not others.
Please check it out:
<?php
if(isset($_GET['id']))
{
$id = $_GET['id'];
$user_id = $_SESSION['SESS_MEMBER_ID'];
echo "<a href='chat.php'>Chat</a> ";
$qry = "SELECT id FROM favourites WHERE favourite_id = '$id' AND id = $user_id";
$result = mysql_query($qry);
if(mysql_num_rows($result) > 0)
{
echo "<a href='delete-favourite-exec.php?id=$id'>Delete from favourites</a>";
}
else
{
echo "<a href='favourite-exec.php?id=$id'>Add to favourites</a>";
}
?>