解决方案 »

  1.   

    <!DOCTYPE html>
    <html>
    <head lang="en">
        <meta charset="UTF-8">
        <!--适应IE-->
        <meta http-equiv="X-UA-COMPATIBLE" content="IE-edge">
        <title>我的博客</title>
        <link href="dist/css/bootstrap.min.css" rel="stylesheet">
        <script src="scripts/jquery-2.1.3.min.js"></script>
        <script src="dist/js/bootstrap.min.js"></script>
        <script>
            setInterval("linkweb.innerHTML=new Date().toLocaleString()+'星期'+'日一二三四五六'.charAt(new Date().getDay());",1000);
        </script>
        <title>Myblog</title>
             <?php
                $con=mysql_connect("localhost","root","");
                if(!$con)
                {
                die('Cound not connecnt the db!'.mysql_error());
                }
                mysql_select_db("the_blog");
                mysql_query("set names 'utf8'");
                $result=mysql_query("select * from the_blog_type");
                $result1=mysql_query("select * from the_blog_information");
                ?>
    </head>
    <body>
    <nav class="navbar navbar-inverse navbar-static-top">
        <div class="container-fluid">
            <!-- Brand and toggle get grouped for better mobile display -->
            <div class="navbar-header">
                <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
                    <span class="sr-only"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                <a class="navbar-brand" href="#">馬</a>
            </div>        <!-- Collect the nav links, forms, and other content for toggling -->
            <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
                <ul class="nav navbar-nav">
                    <li class="active"><a href="Myindex.html">主页 <span class="sr-only">(current)</span></a></li>
                    <li><a href="Myresum.html">个人简介</a></li>
                    <li class="dropdown">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">爱生活 <span class="caret"></span></a>
                        <ul class="dropdown-menu" role="menu">
                            <li><a href="Myblog.html">生活记录</a></li>
                            <li><a href="MyDesing.html">设计爱好</a></li>
                            <li><a href="#">做小菜</a></li>
                            <li class="divider"></li>
                            <li><a href="#">Running Man</a></li>
                            <li class="divider"></li>
                            <li><a href="#">See Movies</a></li>
                        </ul>
                    </li>
                </ul>
                <form class="navbar-form navbar-left" role="search">
                    <div class="form-group">
                        <input type="text" class="form-control" placeholder="Search">
                    </div>
                    <button type="submit" class="btn btn-default">搜索</button>
                </form>
                <div class="navbar-right center-block" id="nav-right">
                            <span class="label label-success vertical-middle-sm">
                                <label id="linkweb">
                                </label>
                            </span>
                </div>        </div><!-- /.navbar-collapse -->
        </div><!-- /.container-fluid -->
    </nav>
    <div class="container-fluid">
        <div class="row-fluid">
            <div class="col-md-2">
                <div class="panel panel-default">
                    <div class="panel-body">
                        <div class="page-header">
                            <h2>日志</h2>
                        </div>
                        <ul class="nav nav-pills nav-stacked">
                              <?php
                                               while($row=mysql_fetch_array($result)){
                                                   echo "<li><a href='BlogTitle.php?id=".$row['type_id']."'>".$row['type_name']."</a></li>";
                                                    }
                                                    ?>
                        </ul>
                        <div class="page-header">
                            <h3>标签</h3>
                        </div>
                        <div class="nav nav-pills nav-stacked">
                            <li><a href="#">标签1</a></li>
                            <li><a href="#">标签1</a></li>
                            <li><a href="#">标签1</a></li>
                            <li><a href="#">标签1</a></li>
                            <li><a href="#">标签1</a></li>
                            <li><a href="#">标签1</a></li>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-md-10">
                <div class="panel panel-default">
                    <div class="page-header">
                    <div class="panel-body">
                   <?php
                       while($r=mysql_fetch_array($result1)){
                      <p><strong>所有日志 <small>[1033]</small></strong></p>
                        <h3><strong>[置顶]<span class="text-danger">$r['tb_blog_title']</span>!</strong></h3>
                        <small class="text-muted">$r['tb_blog_date']</small>
                      <br>
                       <h2>$r['tb_blog_title']</h2>
                       <h4>$r['tb_blog_user']</h4>
                       <p>$r['tb_blog_content']</p>
                       <small class="text-danger"><a href="#">阅读全文>></a> </small>
                       <br>
                       <p class="text-warning"><a href="#">分类:$r['tb_blog_type']  </a> |<a href="#"> 阅读(20101) </a> | <a href="#"> 评论(10)</a> </p>
                       }
                       
                           ?>
                    </div>
            </div>
        </div></div>
    </body>
    </html>
    如上代码,错误如下
      

  2.   

    你112行直接用<p>标签,PHP解析是不认的,把那段html文本echo出来,
    像“while($row=mysql_fetch_array($result)){
                                                   echo "<li><a href='BlogTitle.php?id=".$row['type_id']."'>".$row['type_name']."</a></li>";
                                                    }”
    这段一样
      

  3.   

    你是怎么while的,是不是代码写错了
      

  4.   

    你把html语言直接写入循环体肯定会报错的。
      

  5.   


                   <?php
                       while($r=mysql_fetch_array($result1)){
                      <p><strong>所有日志 <small>[1033]</small></strong></p>
                        <h3><strong>[置顶]<span class="text-danger">$r['tb_blog_title']</span>!</strong></h3>
                        <small class="text-muted">$r['tb_blog_date']</small>
                      <br>
                       <h2>$r['tb_blog_title']</h2>
                       <h4>$r['tb_blog_user']</h4>
                       <p>$r['tb_blog_content']</p>
                       <small class="text-danger"><a href="#">阅读全文>></a> </small>
                       <br>
                       <p class="text-warning"><a href="#">分类:$r['tb_blog_type']  </a> |<a href="#"> 阅读(20101) </a> | <a href="#"> 评论(10)</a> </p>
                       }
                        
                           ?>
                    </div>
    修改为
    <?php
       while($r=mysql_fetch_array($result1)){ ?>
      <p><strong>所有日志 <small>[1033]</small></strong></p>
        <h3><strong>[置顶]<span class="text-danger"><?php echo $r['tb_blog_title']; ?></span>!</strong></h3>
        <small class="text-muted"><?php echo $r['tb_blog_date']; ?></small>
      <br>
       <h2><?php echo $r['tb_blog_title']; ?></h2>
       <h4><?php echo $r['tb_blog_user']; ?></h4>
       <p><?php echo $r['tb_blog_content']; ?></p>
       <small class="text-danger"><a href="#">阅读全文>></a> </small>
       <br>
       <p class="text-warning"><a href="#">分类:<?php echo $r['tb_blog_type']; ?>  </a> |<a href="#"> 阅读(20101) </a> | <a href="#"> 评论(10)</a> </p>
       <?php
        }
        
           ?>
    </div>
      

  6.   

    同楼上 <p>等标签PHP是不解析的 如果你要在脚本内输出 需要echo "<p>"; 引号包起来  否则你就如同楼上 将脚本嵌入页面中