PHP回显标签中的代码?

时间:2014-07-31 10:42:01

标签: php mysqli

由于某种原因,除非我忽略了一些东西,这段代码在这里:

<?
include_once("connect.php");
$sql = "SELECT * FROM categories ORDER BY category_title ASC";
$res = mysqli_query($con,$sql) or die(mysql_error());
$categories ="";
if (mysqli_num_rows($res) > 0) {
    while($row = mysqli_fetch_assoc($res)){
        $id = $row['id'];
        $title = $row['category_title'];
        $description = $row['category_decription'];
        $categories .= "<a href='#' class='cat_links'>".$title." - <font size='-1'>".$description."</font></a>";
    }
    echo $categories;
} else {

    echo"<p>There are no categories available yet.</p>";
}

?>

似乎将此反映在页面上:

  

0){while($ row = mysqli_fetch_assoc($ res)){$ id = $ row [&#39; id&#39;]; $ title = $ row [&#39; category_title&#39;]; $ description = $ row [&#39; category_decription&#39;]; $ categories。=&#34;&#34;。$ title。&#34; - &#34;。$ description。&#34;&#34 ;; } echo $ categories; } else {echo&#34;   目前还没有类别。

     

&#34 ;; }?&gt;

我做错了什么?

提前致谢!

1 个答案:

答案 0 :(得分:0)

将代码从<?更改为<?php。短标签可以是disabled via a configuration setting,并且通常在生产中关闭。