<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
*{
margin: 0;
padding: 0;
border:0;
font-size: 18px;
font-family:"Arial Unicode MS", "Arial";
 }
 body{
 background-color:#000000;
 }
 #main{
 width:765px;
 margin:auto;
 }
 #top{
 width:765px;
 margin:auto;
 float:left;
 }
 .logo{
 width:765px;
 height:150px;
 margin:auto;
 float:left;
 }
 .img_logo{
 width:765px;
 height:150px;
 margin:auto;
 }
 #director{
 width:765px;
 margin:auto;
 float:left;
 }
 .menu_top{
 margin:auto;
 float:left;
 background-image:url(img/nav_bg.jpg);
 }
 .menu_a{
 font-size:22px;
font-weight:bolder;
color:#FFFFFF;
}
</style>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head><body>
<div id="main">
<div id="top">
<!--注册登录-->
  
<!--注册登录-->
<!--logo-->
  <div class="advertising_top"> <img src="img/top.jpg" class="img_logo" /></div>
<!--logo结束-->
<!--导航开始-->
<div id="director">
<script language="php">
<?php
$link=mysql_connect('localhost','root','5225')or die('Could not connect:'.mysql_error());
mysql_select_db('matv')or die ('Could not select database');
$level="SELECT CategoryName FROM ma_category where CategoryLevel=1 ";
mysql_query('set Names "UTF8"');  /*db编码转为utf-8,要先转再查询,不然会乱码*/
$result=mysql_query($level);      /*执行sql语句*/
$row=mysql_fetch_array($result);
$thename=$row['theName'];while($line = mysql_fetch_array($result,MYSQL_ASSOC))
    {
  echo "<div class='menu_top'><a target='_self' class='menu_a' href=''>{$line['CategoryName']}</a></div>";
}
mysql_free_result($result);
mysql_close($link);
?>
</script>
</div>
<!--导航结束-->
</div></div>
</body>
</html>

解决方案 »

  1.   

    怎么无效了?你不会是直接在浏览器中浏览本地的php文件吧。。
      

  2.   

    上面的代码是在dw里面输入的   php的代码 我单独用php文件执行是没问题的  但是复制在这里  缺无显示啊  
    查看网页源代码如下:<!--导航开始--> 
    <div id="director"> 
    <script language="php"> 
    <?php
    $link=mysql_connect('localhost','root','5225')or die('Could not connect:'.mysql_error());
    mysql_select_db('matv')or die ('Could not select database');
    $level="SELECT CategoryName FROM ma_category where CategoryLevel=1 ";
    mysql_query('set Names "UTF8"');  /*db编码转为utf-8,要先转再查询,不然会乱码*/
    $result=mysql_query($level);      /*执行sql语句*/
    $row=mysql_fetch_array($result);
    $thename=$row['theName'];
     
    while($line = mysql_fetch_array($result,MYSQL_ASSOC))
        {
      echo "<div class='menu_top'><a target='_self' class='menu_a' href=''>{$line['CategoryName']}</a></div>";
    }
    mysql_free_result($result);
    mysql_close($link);
    ?>
    </script> 
    </div> 
    <!--导航结束--> 运行里面 localhost...那么启动的  他没有读php那段代码我感觉
      

  3.   

    将<?p ?>去掉试试?你这里有两对php语言标识。
      

  4.   

    怎么还搞出<script language="php">这样一个标签。。你发上来的代码是个html文件?
      

  5.   

    嗯  是html文件  要改成.php么?
      

  6.   

    嗯  是html文件  要改成.php么?
    我改了.php文件  但是html部分没了啊 !~
      

  7.   

    如果你非要让服务器用PHP模块解析html文件,就必须在Web服务器中修改相关的配置,比如Apache的话,修改httpd.conf配置文件并重启,不推荐这么做。
    AddType application/x-httpd-php .php .html .htm