Home  >  Article  >  Backend Development  >  小弟我用flex+php+mysql读取数据显示出现了有关问题!看下写法如何改?

小弟我用flex+php+mysql读取数据显示出现了有关问题!看下写法如何改?

WBOY
WBOYOriginal
2016-06-13 12:50:59726browse

我用flex+php+mysql读取数据显示出现了问题!看下写法怎么改??
这是BookDAO.php的代码:


   $link = mysql_connect("localhost","***","***");

   mysql_select_db("book");

   mysql_query("SET NAMES 'utf8' ");

   /*返回XML格式的books*/

   $sql = 'SELECT * FROM books';

   $result = mysql_query($sql);

                  echo "";

   echo "\n";

   while($row = mysql_fetch_array($result)){

   echo  "" .$row["id"]."";

   echo  "" .$row["author"]. "";

   echo  "" .$row["title"]. "\n";

   echo  "" .$row["genre"]. "\n";

   echo  "" .$row["price"]. "\n";

   echo  "" .$row["publish_date"]. "\n";

   echo  "" .$row["description"]. "\n";

   }

   echo "
\n";


   mysql_close($link);
?>

在mxml的显示结果是:由于放不上图片我就把结果简单的样子数出来:
             你好!
   这就是datagrid显示数据的内容,把auhtor标签也显示在页面上,而不是只显示  “你好!”  这个内容。。。。
   求写法?
      
------解决方案--------------------
htmlspecialchars()把你的XML字符串放进去,之后打印出去,这是因为你没用Header指明content-type的原因。

你直接header("Content-Type:xml");,后面代码不变,浏览器一样可以打印出带标签的XML。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn