Here's the situation. I am a beginner
I have a table called favorite which stores Id's of the sender and receiver (To favorite list a user). I have done the php coding to add and remove from favorites
This is the form for submitting the form to addfav.php
<form method="post" action="addfav.php" id="addfav">
<td width="10%"><img src="images/watchlist.png" width="24" /></td>
<td align="left"><a href="javascript:{}" onclick="document.getElementById('addfav').submit(); return false;">Add to Favourite</a></td>
<input type="hidden" value=" <?php echo $temp; ?>" name="toid" />
</form>
Similarly i have another form for removing from favorite
<form method="post" action="remfav.php" id="remfav">
<td width="10%"><img src="images/watchlist.png" width="24" /></td>
<td align="left"><a href="javascript:{}" onclick="document.getElementById("remfav").submit(); return false;">Remove</a></td>
<input type="hidden" value=" <?php echo $temp; ?>" name="toid" />
</form>
Both the PHP's are workking... What i want is to use an if condition to check whether the user is already added and display the add/remove form accordingly
I Have the sql query with me
$result1 = mysql_query("SELECT * FROM `favourite` WHERE `sendfrom`='".$_SESSION["id"]."' AND sendto="ID of current user");
$num_rows1 = mysql_num_rows($result1);
So if $num_rows1 returns 1 means there is value in the table then REMOVE must appear else ADD.
I Tried to encapsulate both the form inside a php tag with an If conditon.. but the java script doesn't work..
PLs Help