i hoping to create a recursive function which i don\'t have an idea yet
this is my code to fetch category from database
What you need to do, is build a recursive function. That is, a function that calls itself within. An example:
function getCategories($parent=0) {
$res = mysql_query("SELECT * FROM categories WHERE category_parent = '$id' ORDER BY left ASC");
if (mysql_num_rows($res) > 0) {
$category = mysql_fetch_object();
echo '';
echo '- ' . $category->category_name . '';
getCategories($category->category_id);
echo '
';
}
}
If I've made any typos in regards to table and column names then obviously swap them out for the correct values.