:::

2-1 index.php(遞迴範例)

<?php
$root_pass="12345";    //資料庫root密碼
$db_name="test";  //資料庫名稱

/* 連資料庫檢查 */
$link=mysql_connect("localhost","root",$root_pass);  //資料庫連線
mysql_select_db("test");
mysql_query("SET NAMES 'utf8'");  //設定語系
error_reporting(0);


//選單第一層
function menu($ofsn="0"){
    $sql="select * from menu where ofsn='$ofsn' order by sn";
    $result=mysql_query($sql);
   
    $class=($ofsn=="0")?"class='sf-menu'":"";
    $opt="";
    while(list($sn,$ofsn,$title,$url)=mysql_fetch_row($result)){
        $subs=menu($sn);
       
        $href=($url=="")?"<a>":"<a href='$url'>";
       
        $opt.="<li>{$href}{$title}</a>$subs</li>";   
    }
   
    if($opt=="")return;
       
    $main="<ul $class>{$opt}</ul>";
    return $main;
}



?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <link rel='stylesheet' type='text/css' media='screen' href='style.css' />
  <title>下拉選單</title>
  </head>
  <body>

    <link rel="stylesheet" type="text/css" href="superfish-1.4.8/css/superfish.css" media="screen">
    <link rel="stylesheet" type="text/css" media="screen" href="superfish-1.4.8/css/superfish-vertical.css" />
    <link rel="stylesheet" type="text/css" media="screen" href="superfish-1.4.8/css/superfish-navbar.css" />
    <script type="text/javascript" src="superfish-1.4.8/js/jquery-1.2.6.min.js"></script>
    <script type="text/javascript" src="superfish-1.4.8/js/superfish.js"></script>
    <script type="text/javascript" src="superfish-1.4.8/js/supersubs.js"></script>
   
    <script type="text/javascript">
        $(document).ready(function() {
            $('ul.sf-menu').supersubs({minWidth: 8, maxWidth: 27, extraWidth: 1}).superfish({pathClass:  'current'});
        });
    </script>
   
   
    <?php echo menu();?>
   
    <div style="clear:both;"></div>
    <h3>Superfish 下拉選單</h3>
    <ol>
        <li>官網:<a href="http://users.tpg.com.au/j_birch/plugins/superfish" target="_blank">http://users.tpg.com.au/j_birch/plugins/superfish</a></li>
        <li>支援IE6,有延遲出現功能(預設800毫秒),無限子選項,有淡出淡入特效</li>
        <li>支援Tab鍵,可透過hoverIntent 外掛來設定滑鼠敏感度。</li>
        <li>可自訂是否要出現箭頭,具陰影功能,有導覽模式(雙層選單)。</li>
        <li>phpMyAdmin:<a href="http://localhost/phpmyadmin" target="_blank">http://localhost/phpmyadmin</a></li>
    </ol>
   

  </body>
</html>
 


:::

搜尋

QR Code 區塊

https%3A%2F%2Ftad0616.cp22.secserverpros.com%2Fmodules%2Ftad_book3%2Fpage.php%3Ftbdsn%3D241%26tbsn%3D9

書籍目錄

展開 | 闔起

線上使用者

587人線上 (132人在瀏覽線上書籍)

會員: 0

訪客: 587

更多…