I have a PHP
Code that will only show the Add to Favourites Button
not the Remove from Favourites
one. I have tried using if(mysqli_num_rows($result) != 0)
It has the same Result.
<?php
session_start();
$con=mysqli_connect("localhost","UN","PW","DB");
// Check connection
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$id=$_SESSION['user']['id'];
$code='mosP5EvVopNQ3v22rjgaKfmYB';
$result = mysqli_query("SELECT * FROM favourites WHERE user='$id' AND gamecode='$code'");
$num_rows = mysqli_num_rows($result);
if ($num_rows == 0) {
echo'<img src="/add.gif" height="100" width="100" title="Add to Favourites">';
}
else {
echo'<img src="/remove.gif" height="100" width="100" title="Remove from Favourites">';
}
mysqli_close($con);
?>