帝国软件
  设为首页 加入收藏 关于我们
 
解密帝国网站管理系统
栏 目:
 
您的位置:首页 > 技术文档 > PHP编程
查询数据生成XML并显示的例子(基于PHP+MySQL)
作者:匿名 发布时间:2002-12-21 来源:红都网
//TABLE



create table tableurl(



id int(5),



sort int(2),



click int(6),



getday date,



name char(30),



link char(40),



brief char(50),



PRIMARY KEY (id)



)







//XML FILE



------------------------------



<?php



require("db.inc.php");







if(empty($order))



{$order='hot';



}



switch($order)



{



case 'hot':



$querystring="select * from tableurl order by click desc LIMIT 20";



break;



case 'new':



$querystring="select * from tableurl order by getday desc LIMIT 20";



}



$result=mysql_query($querystring,$db);



echo "<?xml version="1.0" encoding="gb2312"?>n";



echo "<?xml-stylesheet type="text/xsl" href="sitelist.xsl"?>";



echo "<URL>n";



while ($data=mysql_fetch_array($result))



{ echo "<WEBSITE ID="".$data["id"]."">n";



echo "<NAME>".$data["name"]."</NAME>n";



echo "<LINK>".$data["link"]."</LINK>n";



echo "<CLICK>".$data["click"]."</CLICK>n";



echo "<DATE>".$data["getday"]."</DATE>n";



echo "<BRIEF>".$data["brief"]."</BRIEF>n";



echo "</WEBSITE>n";



}



echo "</URL>n";



?>







//XSL FILE



------------------------------



<?xml version="1.0" encoding="gb2312" ?>



<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">



<xsl:template match="/">







<html>



<head>



<title>SITELIST.XML.PHP</title>



<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />



<style type="text/css">



body {font-size:9pt;line-height:16pt}



table {font-size:9pt;line-height:16pt}



a:link {color:#000000;text-decoration:underline}



a:visited {color:#000000;text-decoration:underline}



a:active {color:#000000;text-decoration:underline}



a.white:link {color:#ffffff;text-decoration:underline}



a.white:visited {color:#ffffff;text-decoration:underline}



a.white:active {color:#ffffff;text-decoration:underline}



</style>



</head>



<body>



<p align="center"><a href="sitelist.xml.php?order=hot">HOT</a>---<a href="sitelist.xml.php?order=new">NEW</a></p>







<table width="750" align="center" border="0" cellspacing="1" cellpadding="5" bgcolor="#cccccc">



<tr>



<td width="5%" bgcolor="#ffffff">ID</td>



<td width="30%" bgcolor="#ffffff">NAME</td>



<td width="20%" bgcolor="#ffffff">DATE</td>



<td width="5%" bgcolor="#ffffff">CLICK</td>



<td width="40%" bgcolor="#ffffff">BRIEF</td>



</tr>



<xsl:for-each select="URL/*">



<tr>



<td width="5%" bgcolor="#ffffff"><xsl:value-of select="@ID"/></td>



<td width="30%" bgcolor="#ffffff">



<a><xsl:attribute name="href">go.php?id=<xsl:value-of select="@ID"/></xsl:attribute>



<xsl:attribute name="target">_blank</xsl:attribute><xsl:value-of select="NAME"/></a>



</td>



<td width="20%" bgcolor="#ffffff"><xsl:value-of select="DATE"/></td>



<td width="5%" bgcolor="#ffffff"><xsl:value-of select="CLICK"/></td>



<td width="40%" bgcolor="#ffffff"><xsl:value-of select="BRIEF"/></td>



</tr>



</xsl:for-each>



</table>



<p align="center"> <a href="#" onclick="window.close()">CLOSE</a> </p>



</body>



</html>

  
评论】【加入收藏夹】【 】【打印】【关闭
※ 相关链接
 ·数据库查询语言(1)  (2005-03-12)
 ·数据库查询语言(2)  (2005-03-12)
 ·解决在执行数据库查询中的特殊字  (2005-03-12)
 ·如何实现大小写完全匹配的查询  (2005-03-12)
 ·asp+初体验---用c#写的asp+域名查  (2005-03-12)
 ·ASP+中执行简单的Select查询,并  (2005-03-12)
 ·一个用vc开发的域名查询组件(源  (2005-03-12)
 ·错误“操作必须使用一个可更新的  (2005-03-12)
 ·域名登记查询(whois)很复杂吗--方  (2005-03-12)
 ·域名登记查询(whois)很复杂吗--方  (2005-03-12)

   栏目导行
  PHP编程
  ASP编程
  ASP.NET编程
  JAVA编程
   站点最新
·致合作伙伴的欢迎信
·媒体报道
·帝国软件合作伙伴计划协议
·DiscuzX2.5会员整合通行证发布
·帝国CMS 7.0版本功能建议收集
·帝国网站管理系统2012年授权购买说
·PHPWind8.7会员整合通行证发布
·[官方插件]帝国CMS-访问统计插件
·[官方插件]帝国CMS-sitemap插件
·[官方插件]帝国CMS内容页评论AJAX分
   类别最新
·Windows下集成安装Apache,PHP,MYSQ
·Mysql注入:SQL Injection with MyS
·PHP 的来龙去脉
·PHP 的功能概述
·PHP与其它CGI的比较
·PHP 的编译配置详细选项
·php.ini 配置详细选项
·如何写作PHP程序
·Hello,World
·嵌入方法
 
关于帝国 | 广告服务 | 联系我们 | 程序开发 | 网站地图 | 留言板 帝国网站管理系统