i hoping to create a recursive function which i don\'t have an idea yet
this is my code to fetch category from database
Something like this?
function getCategories($mid, $categoryParent = 1)
{
$return = '';
$results = mysql_query("SELECT * FROM categories WHERE category_parent = '$categoryParent' ORDER BY lft ASC", $mid);
while($row = mysql_fetch_array($results)) {
$return .= "- {$row['category_name']}
";
$subs = getCategories($mid, $row['category_id']);
if (!empty($subs)) {
$return .= '';
$return .= $subs;
$return .= '';
}
}
return $return;
}
$mid = mysql_connect($host, $user, $pass);
echo getCategories($mid);
Would print out all your categories, of course fix it to exactly how you want, but that should give you an idea of how recursive functions could work