SELECT iNewsID, iNewsTitle FROM tb_news_CH ORDER BY iNewsID DESC 
直接放phpmyadmin里执行看

解决方案 »

  1.   

    哦,是SQL语句错了,现在还有个问题:
    Warning: Wrong parameter count for mysql_free_result() in D:\work\myphp\khgl\smarty_study\index.php on line 57Warning: Wrong parameter count for mysql_free_result() in D:\work\myphp\khgl\smarty_study\index.php on line 74Warning: Wrong parameter count for mysql_free_result() in D:\work\myphp\khgl\smarty_study\index.php on line 90
    这是怎么回事???????
      

  2.   

    include_once("./comm/Smarty.class.php"); //包含smarty类文件
         define("NUM", 5);                        //定义每次显示的新闻条数     $smarty = new Smarty();                     //建立smarty实例对象$smarty
         $smarty->templates_dir  = "./templates";     //设置模板目录
         $smarty->compile_dir     = "./templates_c";   //设置编译目录
         $smarty->cache_dir        = "./cache";         //设置缓存目录
         $smarty->cache_lifetime = 60 * 60 * 24;      //设置缓存时间
         $smarty->caching        = false;             //这里是调试时设为false,发布时请使用true
         $smarty->left_delimiter = "<{";              //设置左边界符
         $smarty->right_delimiter = "}>";             //设置右边界符      
          $db = mysql_connect("localhost", "root", "") or die("数据库连接错误!");
          mysql_select_db("News", $db);      $NewsID   = $_GET["id"];    //获取新闻编号
          $NewsType = $_GET["type"];  //要显示的新闻类型
          switch($NewsType)
          {
            case 1:
                $dbName = "tb_news_ch";
                break;
            case 2:
                $dbName = "tb_news_in";
                break;
            case 3:
                $dbName = "tb_news_mu";
                break;
          }      
      $strQuery = "SELECT vcNewsTitle, ltNewsContent FROM $dbName where iNewsID='$NewsID' ";
          $result   = mysql_query($strQuery) or die("数据库查询错误!");
          if($row = mysql_fetch_array($result))
          {
           //$array[] = array("NewsTitle"=>$row["vcNewsTitle"], "NewsContent"=>$row["ltNewsContent"]); 
    $smarty->assign("NewsTitle", $row["vcNewsTitle"]);
    $smarty->assign("NewsContent", $row["ltNewsContent"]);
          }
      //print_r($array);         
             mysql_free_result($result);
             $smarty->display("news.tpl");
          mysql_close($db);
    摸班:
    <title><{$NewsTitle}> </title>
    <div align="center" class="NewsTitle"><{$NewsTitle}></div>
    <p>-<{$NewsContext}></p>怎么只显示标题,而不显示内容呢?
      

  3.   

    哈哈,是<{$NewsContent}>,写错了,最近眼神不好,忙了一下午,郁闷哦