<?
header("content-type:application/vnd.ms-excel");
header("content-disposition:filename=test.xls");
$sql = "select ";
if ( $http_post_vars["c1"] == "on" ) $sql .= "hdid, ";
if ( $c2 == "on" ) $sql .= "location, ";
if ( $c3 == "on" ) $sql .= "getip, ";
if ( $c4 == "on" ) $sql .= "type, ";
if ( $c5 == "on" ) $sql .= "pcusername, ";
if ( $c6 == "on" ) $sql .= "usergroup, ";
if ( $c7 == "on" ) $sql .= "ram, ";
if ( $c8 == "on" ) $sql .= "cpu, ";
if ( $c9 == "on" ) $sql .= "disk, ";
if ( $c10 == "on" ) $sql .= "lanmac, ";
if ( $c11 == "on" ) $sql .= "monitor, ";
if ( $c12 == "on" ) $sql .= "attachhd, ";
if ( $c13 == "on" ) $sql .= "software, ";
if ( $c14 == "on" ) $sql .= "weblog, ";
if ( $c15 == "on" ) $sql .= "other ";
if ( substr($sql, -2) == ", " ) $sql = substr($sql, 0, strlen($str)-2) . " ";
$sql .= "from pcinfo order by hdid asc";
$link = mysql_connect('127.0.0.1','root','0000') or die("無法連線!請連絡管理者!");
mysql_select_db('hdinfo',$link) or die("無法連到資料庫!請連絡管理者!");
//echo $sql;
$result = mysql_query("$sql");
$total=mysql_num_rows($result);
//echo $total;
if ( $http_post_vars["c1"] == "on" ) echo "硬件编号/t";
if ( $c2 == "on" ) echo "所属厂别/t";
if ( $c3 == "on" ) echo "所分配的ip/t";
if ( $c4 == "on" ) echo "机器型号/t";
if ( $c5 == "on" ) echo "使用者名称/t";
if ( $c6 == "on" ) echo "使用者部门/t";
if ( $c7 == "on" ) echo "内存配置/t";
if ( $c8 == "on" ) echo "cpu配置/t";
if ( $c9 == "on" ) echo "硬盘配置/t";
if ( $c10 == "on" ) echo "网卡型号及mac/t";
if ( $c11 == "on" ) echo "显示器型号/t";
if ( $c12 == "on" ) echo "其所附的硬件/t";
if ( $c13 == "on" ) echo "所安装的软件/t";
if ( $c14 == "on" ) echo "上网申请纪录/t";
if ( $c15 == "on" ) echo "其他/t";
echo " /t/n";
for ($i=0 ;$i<$total; $i++)
{
$result_row=mysql_fetch_row($result);
while (list($no,$content)=each($result_row))
{
echo "$content/t";
}
echo " /t/n";
}
以上是根据不同的选项查询不同的列,然后生成excel 的文件
新闻热点
疑难解答