merhabalar,
ekranın sol kenarında tree view ağaç şeklinde bir menu oluşturmak istiyorum bunun için 2 tablom var bunlar birisi root diğeride submnuleri çağıracak, ve submenu seçildiğinde ise ilgili submenununun php dosyası ekrana include edilecek. ama bir türlü buna gerekli kodu oluşturamadım yardımcı olabilirmisiniz.
solmenutr tablosu solsubmenutr tablosu
index solmenuname index indexrefno submenuname menulink
1 elektronik 1 1 direnc direnc.php
2 bilgisayar 2 2 hp hp.php
3 uydu 3 1 kondansator kondansator.php
4 1 transistor transistor.php
5 2 dell dell.php
6 3 dreambox dreambox.php
databasden ekran solunda tree view menu oluşturma
Re: databasden ekran solunda tree view menu oluşturma
evet sonunda problem cozuldu. ihtiyac duyan arkadaslar asagıdaki kodlarla bunu gerçekleştirebilir.
php index dosyamızdaki kod aşağıdadır.
drop down.js dosyası aşağıdadır.
leftmenu.css dosyası aşağıdaki gibidir.
php index dosyamızdaki kod aşağıdadır.
Kod: Tümünü seç
<script type="text/javascript" src="drop_down.js"></script>
<style type="text/css">
@import "leftmenu.css";
</style>
<ul id="nav">
<?
$totalrow=0;
$sql="SELECT * FROM solmenutr";
$result=mysql_query($sql);
$totalrow=mysql_numrows($result);
if($totalrow>0)
{
$i=0;
while($i < $totalrow)
{
$solmenutrindexno=mysql_result($result,$i,"index");
$solmenuname=mysql_result($result,$i,"solmenuname");
echo ("<li> <a href=>" .$solmenuname. "</a>");
echo ("<ul>");
$totalrow2=0;
$sql2="select * from SOLSUBMENUTR WHERE indexnoref= \"$solmenutrindexno\" ";
$result2 = mysql_query($sql2);
$totalrow2=mysql_numrows($result2);
if( $totalrow2 > 0)
{
$j=0;
while ($j < $totalrow2)
{
$submenuname = mysql_result($result2,$j,"submenuname");
$submenulink= mysql_result($result2, $j, "submenulink");
echo ("<li><a href=".$submenulink.">".$submenuname."</a></li>");
$j++;
}
echo ("</ul>");
echo ("</li>");
}
$i++;
}
echo("</ul>");
}
?>
Kod: Tümünü seç
// JavaScript Document
startList = function() {
if (document.all&&document.getElementById) {
navRoot = document.getElementById("nav");
for (i=0; i<navRoot.childNodes.length; i++) {
node = navRoot.childNodes[i];
if (node.nodeName=="LI") {
node.onmouseover=function() {
this.className+=" over";
}
node.onmouseout=function() {
this.className=this.className.replace(" over", "");
}
}
}
}
}
window.onload=startList;
Kod: Tümünü seç
body {
font-family: Arial;
font-size: 14px;
font-weight: bold;
color: #FFFFFF;
text-decoration: none;
}
ul {
margin: 0;
padding: 0;
list-style: none;
width: 150px; /* Width of Menu Items */
border-bottom: 1px solid #ccc;
}
ul li {
position: relative;
}
li ul {
position: absolute;
left: 149px; /* Set 1px less than menu width */
top: 0;
display: none;
}
/* Styles for Menu Items */
ul li a {
display: block;
/*text-decoration: none;*/
/*color: #777;*/
color: #FFFFFF;
background: #D00154; /* IE6 Bug */
padding: 5px;
border: 1px solid #ccc; /* IE6 Bug */
border-bottom: 0;
}
/* Holly Hack. IE Requirement \*/
* html ul li { float: left; height: 1%; }
* html ul li a { height: 1%; }
/* End */
li:hover ul, li.over ul { display: block; } /* The magic */