$sqlAandM = "SELECT * FROM #_directoryBase_categories WHERE parent_id='1' LIMIT 6";
$getAandM = $wpdb->get_results($sqlAandM, ARRAY_A);
$listAandMMain = "";
foreach ($getAandM as $getAandMExtend){
if($getAandMExtend[is_parent] = "yes") {
$listAandMMain .= "$getAandMExtend[dir_categories]";
//echo $listAandMMain;
}
elseif($getAandMExtend[is_parent] = "no") {
$listAandMSub .= "<li>$getAandMExtend[dir_sub_categories]</li>";
}
}
MYSQL TABLE Structure:
This is currently outputting
Visual of what is being outputted:
Notice that for some reason the a blank list item has been added to the out put for the sub categories. I’m limiting to only 6 as I’ll style them below the “Advertisign and Media” main category item.
Is there something that can be done to skip that extra iteration without directly targeting it through mysql with separate queries?
I don’t have enough rep to post images within the body, but they add a ton of clarity of what exactly is happening.
Pretty sure:
should be
Because two equals (
==
) is asking if x is equals to y.One equals (
=
) is x is equals to the contents of y and therefore won’t compare the two.So from the above you want
==
as you are comparing not values not assigning them.