emlak21 Posted August 16, 2023 Share Posted August 16, 2023 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; } } Quote Link to comment https://forums.phpfreaks.com/topic/317194-category-and-subcategory-function-help/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.