I'm trying to loop a table by comparing the results that I get from another table but it seems to be skipping the null index value.
What I want to get from the result is if one of the value of $a can be found on $b, it should echo the loop that it is associated or rather the index of that array.
<ol>
<?php
$questions = db_query("SELECT * FROM tbl_questions");
while ($quests = $questions->fetch_assoc()) {
$b[] = $quests['question_id'];
$comp = db_select("SELECT * FROM tbl_votes WHERE `user_id` = $userids");
foreach($comp as $compare){
$check[] = $compare['question_id'];
}
$a = array_intersect($b, $check);
if($a){
echo "<li><a class='qstyle' href='questions/".$quests['question_id'].".php'>".$quests['question_title']."</a></li>";
}
elseif($quests['question_live'] == 1){
echo "<li><strong><a class='qstyle' href='vote_page.php?var=".$quests['question_id']."'>".$quests['question_title']."</a></strong></li>";
}
elseif($quests['question_live'] == 0){
echo "<li style='color:#968c8d'>".$quests['question_title']."</li>";
}
}
?>
</ol>