Jump to content

Recommended Posts

Hello
Can you help for the Main Category and Subcategory,
I'm pulling the Satılık, Kiralık and Günlük Kiralık data from the emlak_durum table
I'm pulling the Main Category and Subcategory data in the emlak_durum table,
If the Main Category is single, this way the URL structure is "kategori/Satılık_Konut" if there are subcategories of the main category, how do we get it to give "kategori/Satılık_Konut_Villa"
 

function menukategori($katid = 0, $string = 0, $ustid = 0, $menuurl = ""){
    global $db;
    global $htc;
    $query = $db->prepare("SELECT * FROM emlak_kategori WHERE ustid=? AND dil=? ORDER BY sira ASC");
    $query->execute(array($katid, $_SESSION["admin_dil"]));
    $islem = $query->fetchAll(PDO::FETCH_ASSOC);
    if($query->rowCount()){
        foreach ($islem as $Row){
            $selected = '';
            if($menuurl == $htc['emlakkategoriurl'].'/'.$Row['seo']){
                $selected = 'selected';
            }
            // Verileri emlak_durum tablosundan çekin
            $query_durum = $db->prepare("SELECT * FROM emlak_durum WHERE dil=?");
            // İstediğiniz durumu seçin
            $query_durum->execute(array($_SESSION["admin_dil"]));
            $durumlar = $query_durum->fetchAll(PDO::FETCH_ASSOC);
            foreach ($durumlar as $durum) {
                $alt_seo = $durum['url'].'_'.$Row['seo'];
                $alt_menuurl = $htc['emlakkategoriurl'].'/'.$alt_seo;
                // Alt kategori URL yapısı
                echo '<option data-menuurl="'.$alt_menuurl.'" data-if="'.$htc['emlakkategoriurl'].'/'.$durum['url'].'_'.$Row['seo'].'" '.$selected;
                echo ' value="'.$alt_menuurl.'">('.$durum['adi'].') '.str_repeat('=>', $string).$Row['adi'].'</option>';
            }
            menukategori($Row['id'], $string + 1, $ustid, $menuurl);
        }
    } else {
        return false;
    }
}

 

Link to comment
https://forums.phpfreaks.com/topic/317194-category-and-subcategory-function-help/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.