Tutorials
Php Sınısız Kategori Menü |
2 Mesajlar | 708 Okunma |
$categories = array();
$res = $db->get_results("SELECT * FROM kategori");
foreach($res as $row){
$parent = intval($row->alt);
if (!isset($categories[$parent])) {
$categories[$parent] = array();
}
$categories[$parent][] = $row;
}
$category_string = "";
function build_categories_options($parent, $categories, $level) {
global $kat_id;
global $category_string;
if (isset($categories[$parent]) && count($categories[$parent])) {
$level .= " - ";
foreach ($categories[$parent] as $category) {
$katidd = $category->id;
$opt_value = substr($level.$category->kategori_adi,3);
if($katidd == $kat_id){
$category_string .= '';
}else{
if($category->alt == 0){
$category_string .= '';
}else{
$category_string .= '';
}
}
build_categories_options($katidd, $categories, $level);
}
$level = substr($level, -3);
}
return $category_string;
}
$category_options = build_categories_options(0, $categories, '');
$category_options = '';
echo $category_options;
?>