while ( $org = $orgid->fetch_array()) {
$getorg = "SELECT Name FROM organisations WHERE ID='" . $org['orgid'] . "'";
$orgname = $db->query($getorg) or die ($db->error());
if ( $org['orgid'] !== false ) {
echo("<td>" . $orgname->fetch_object()->Name . "</td>" );
$hasOrg = true;
}
else {
echo("<td>Player not in an org.</td>");
}
}
Here is my code, and above is the result (the link).
CG Staff is the organization, for players with it.
The query only has two results, so that is why it is returning true all the time. How, though, can I make it say something in the for rows in the table that don't have a result?
In your if statement
if ( $org['orgid'] !== false )
$org['orgid'] has to be identical to FALSE. A zero(0) or NULL will evaluate as true, make sure that column contains a FALSE.
You could re-write this like this to evaluate the contents of $org['orgid']
if ( $org['orgid'] ) {
echo("<td>" . $orgname->fetch_object()->Name . "</td>" );
$hasOrg = true;
} else {
echo("<td>Player not in an org.</td>");
}