Does anyone know why this code is not working it will display the Unfollow bit but not the follow part. all it should do is say follow if they are not following that person and unfollow if they are. I have tried using Just if(row['following'])
But it has the same output.
Thanks
<?php
$con=mysqli_connect("localhost","Username","Password","DB");
// Check connection
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
session_start();
$follower=$_SESSION['user']['id'];
$following=$_GET['id'];
$result = mysqli_query($con,"SELECT * FROM following WHERE follower='$follower' AND following='$following'");
while($row = mysqli_fetch_array($result)) {
if(isset($row['following'])){
?>
<a href="/profile/unfollow.php/?id=<?php echo $dnn['id']; ?>">
<?php
echo'<div id="button">';
echo'Unfollow <?php echo $dnn["username"]; ?>';
echo'</div>';
}
else{
?>
<a href="/profile/follow.php/?id=<?php echo $dnn['id']; ?>">
<?php
echo'<div id="button">';
echo'Follow <?php echo $dnn["username"]; ?>';
echo'</div>';
}
mysqli_close($con);
}
?>