i am struggling a bit with a PDO problem. I want to check if a returned column has any value in it.
I am doing this:
function populateAltsDropdown($list)
{
echo "<div class='dropdown'>
<button class='btn btn-secondary btn-sm dropdown-toggle' type='button' id='dropdownMenuButton' data-toggle='dropdown' aria-haspopup='true' aria-expanded='false'>
Alts
</button>
<div class='dropdown-menu' aria-labelledby='dropdownMenuButton'>";
foreach ($list as $row)
{
if($row['name'] != null) {
echo "<a class='dropdown-item disabled' href='#'>" . $row['name'] . "</a>";
}
else
{
echo "No Alts";
}
}
echo "</div></div>";
}
I don't know how to make $row['name'] != null
work.
This is what i have on $list:
function selectAlts($conn,$character_id)
{
$stmt = $conn->prepare('SELECT cm.alt_id,c.name FROM charactermapping cm
LEFT JOIN characters c
ON (cm.alt_id = c.character_id)
WHERE c.active = TRUE and cm.main_id = ?');
$stmt->execute([$character_id]);
return $stmt;
}
I could have values in that list like:
ID--------Name
"1002303","Name 1"
"2132444","Name 2"
"4324323",null
"4343433",null
I want some help in filtering our the values that do not have any name in them, the ones with null.