Veritabanı: http://img823.imageshack.us/img823/4770/fishq.png
Kodlarım:
<?php
$dbhost = "localhost";
$dbkullanici = "root";
$dbsifre = "";
$dbadi = "portal";
$baglanti = mysql_connect($dbhost,$dbkullanici,$dbsifre);
if (! $baglanti )
{
echo "mysql baglanti kurulamadi!";
}
mysql_select_db($dbadi,$baglanti) or die ("veritabanina baglanti yapilamadi!");
$query=mysql_query("SELECT * FROM menu ORDER BY id");
while ( $row = mysql_fetch_assoc($query) )
{
$menu_array[$row['id']] = array('name' => $row['kat'],'id' => $row['id'],'seo' => $row['seo'],'parent' => $row['ana']);
}
//recursive function that prints categories as a nested html unorderd list
function generate_menu($parent, $aktif)
{
$has_childs = false;
//this prevents printing 'ul' if we don't have subcategories for this category
global $menu_array;
//use global array variable instead of a local variable to lower stack memory requierment
foreach($menu_array as $key => $value)
{
if ($value['parent'] == $parent)
{
//if this is the first child print '<ul>'
if ($has_childs === false)
{
//don't print '<ul>' multiple times
$has_childs = true;
if ($value['id'] == '1') {
echo '
<ul class="sf-menu sf-navbar sf-style-blue" id="ustmenu">';
} else {
echo '
<ul>';
}
$okla = false;
}
echo '
<li';
if ($okla === false)
{
$okla = true;
echo ' class="menuparent"';
}
echo '><a href="' . $value['seo'] . '/">' . $value['name'] . '</a>';
generate_menu($key, $aktif);
//call function again to generate nested list for subcategories belonging to this category
echo '</li>';
}
}
if ($has_childs === true) echo '
</ul>';
}
generate_menu(0,7);
?>Superfish: http://users.tpg.com.au/j_birch/plug...rfish/#sample4İlla bu olacak diye bişeyde yok. Wordpress in veya drupalın kullandığı fonksiyonlar da olabilir. Biraz aradım onları ama bulamadım.
İlgilenen arkadaşlara şimdiden teşekkürler.