I have issues with this pretty simple database query. The opening if-condition is true and working.
The problem comes with the if/if/else inside. The second statement, when the active user has some connections, but the profile he is visiting does not, is working. Results in "invite to your crew".
But if the first state of nature is true, when neither the active user nor the profile owner has connections, my query isn't working. It will always result in the else statement ("join crew"), which should only happen when the profile owner has at least one connection ($countProfileCon!==0), in that case it won't matter how many connections the active user has.
I can't see why.
if ($countCurrent==0 && $countFormer==0) {
$activeConnectionQuery = $DBcon->query("SELECT * FROM tbl_current_userconnections WHERE user_id=".$_SESSION['userSession']);
$countActiveCon=$activeConnectionQuery->num_rows;
$profileConnectionQuery = $DBcon->query("SELECT * FROM tbl_current_userconnections WHERE user_id=".$_GET['user']);
$countProfileCon=$profileConnectionQuery->num_rows;
if ($countActiveCon==0 && $countProfileCon==0) {
$connect = "<p>create a crew</p>";
}
if ($countActiveCon!==0 && $countProfileCon==0) {
$connect = "<p>invite to your crew</p>";
}
else {
$connect = "<p>join crew</p>";
}
}
tbl_current_userconnections looks like this, when the problem occurs:
user_id connection_id
---------------- ----------------
(it's empty, obviously)
Aucun commentaire:
Enregistrer un commentaire