Good day guys,
I’ve made a sweet favorites function with php mysql and ajax, and its working great. Now I want to show ‘favorite’ when favorite = 0 and show ‘unfavorite’ when favorite = 1
if ($favorites == 0) {
$favorite = '<a href="#" id="' .($id). '" class="favorite_button">Favorite</a>';
}
if ($favorites == 1) {
$unfavorite = '<a href="#" id="' .($id). '" class="unfavorite_button">unFavorite</a>';
}
and echo it in the row as :
<div id="favorites">' .($favorite). ' ' .($unfavorite). '</div>
The problem is: when favorite = 0, both $favorite and $unfavorite are being shown. When favorite = 1 only $unfavorite is being shown correctly. Of course it should be $favorite OR $unfavorite. I assume the problem is clear and simple to you, please assist 🙂
Thanks in advance
It’s easier to use just one variable: