I keep getting a wierd list after running this:
<?php
$query_Category = "SELECT * FROM blog_categories ORDER BY category ASC";
$getCategory = mysql_query($query_Category) or die(mysql_error());
?>
<div id="sheader" style="">Categories</div>
<div class="sbody" style="color:#000 !important;">
<?php
do {
?>
<div><?php echo $row_getCategory['category'];?></div>
<?php
$cat = $row_getCategory['cat_id'];
$query_Subcategory = "SELECT * FROM blog_subcategories WHERE primcat_id = '$cat' ORDER BY subcategory ASC";
$getSubCategory = mysql_query($query_Subcategory) or die(mysql_error());
$row_getSubCategory = mysql_fetch_assoc($getSubCategory);
$str = $row_getSubCategory['subcategory']; $subcategory = explode(',', $str);
foreach ($subcategory as $arraysubcat)
{
echo '<div>' . $arraysubcat . '</div>';
}
} while ($row_getCategory = mysql_fetch_assoc($getCategory));
?>
</div>
<?php mysql_free_result($getCategory); ?>
I have a categories table with id & category and a sub categories table with a id, subcategory, & primary category id. I run it and it displays the foreach first randomly.