|
|
|
ปัญหาSave > Excel เลข 0 ตัวหน้าหายครับ Code ด้านในครับ |
|
|
|
|
|
|
|
Code (PHP)
<?php
$strExcelFileName="Report_Asset_Management.xls";
header("Content-Type: application/x-msexcel; name=\"$strExcelFileName\"");
header("Content-Disposition: inline; filename=\"$strExcelFileName\"");
header("Pragma:no-cache");
mysql_connect("localhost","root","1234");
mysql_select_db("asset");
mysql_query("SET NAMES UTF8");
$sql=mysql_query("SELECT * FROM tb_gadget,tb_department,tb_gadgettype,tb_brand,tb_cpu,tb_mb,tb_ram,tb_hdd,tb_vga,tb_mo,tb_os
where
tb_gadget.Gadgettype_id = tb_gadgettype.Gadgettype_id
AND
tb_gadget.Department_user = tb_department.Department_id
AND
tb_gadget.Brand_tb = tb_brand.Brand_id
AND
tb_gadget.cpu_tb = tb_cpu.cpu_id
AND
tb_gadget.mb_tb = tb_mb.mb_id
AND
tb_gadget.ram_tb = tb_ram.ram_id
AND
tb_gadget.hdd_tb = tb_hdd.hdd_id
AND
tb_gadget.vga_tb = tb_vga.vga_id
AND
tb_gadget.mo_tb = tb_mo.mo_id
AND
tb_gadget.os_tb = tb_os.os_id
AND
tb_gadget.Gadget_id ORDER BY gadget_id");
$num=mysql_num_rows($sql);
?>
<html xmlns:o="urn:schemas-microsoft-com:office:office"xmlns:x="urn:schemas-microsoft-com:office:excel"xmlns="http://www.w3.org/TR/REC-html40">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<strong>รายงานทรัพย์สิน วันที่ <?php echo date("d/m/Y");?> ทั้งหมด <?php echo number_format($num);?> เครื่อง</strong><br>
<br>
<div id="SiXhEaD_Excel" align=center x:publishsource="Excel">
<table width="100%" height="70" border="1" align="center" cellpadding="1" cellspacing="1">
<tr>
<td width="37" align="center" class="h5"><strong>No.</strong></td>
<td width="96" align="center" class="h5"><strong>AssetCode</strong></td>
<td width="50" align="center" class="h5"><strong>Type</strong></td>
<td width="180" align="center" class="h5"><strong> ComBrand </strong></td>
<td width="95" align="center" class="h5"><strong> ComName </strong></td>
<td width="250" align="center" class="h5"><strong> CPU </strong></td>
<td width="160" align="center" class="h5"><strong> Mainboard </strong></td>
<td width="96" align="center" class="h5"><strong> RAM </strong></td>
<td width="200" align="center" class="h5"><strong> Harddisk </strong></td>
<td width="200" align="center" class="h5"><strong> VGA </strong></td>
<td width="170" align="center" class="h5"><strong>MonitorCode</strong></td>
<td width="96" align="center" class="h5"><strong>MoniterBrand</strong></td>
<td width="240" align="center" class="h5"><strong>OS</strong></td>
<td width="300" align="center" class="h5"><strong>Licens</strong></td>
<td width="96" align="center" class="h5"><strong>DatePur</strong></td>
<td width="96" align="center" class="h5"><strong> User </strong></td>
<td width="96" align="center" class="h5"><strong>Depart</strong></td>
<td width="96" align="center" class="h5"><strong>Location</strong></td>
<td width="92" align="center" class="h5"><strong> Details </strong></td>
</tr>
<?php
$objConnect = mysql_connect("localhost","root","1234") or die("Error Connect to Database");
mysql_query("SET NAMES UTF8");
$objDB = mysql_select_db("asset");
/*$strSQL = "SELECT * FROM tb_gadget,tb_department,tb_gadgettype
where
tb_gadget.Gadgettype_id = tb_gadgettype.Gadgettype_id
AND
tb_gadget.Department_user = tb_department.Department_id";*/
$strSQL = " SELECT * FROM tb_gadget,tb_department,tb_gadgettype,tb_brand,tb_cpu,tb_mb,tb_ram,tb_hdd,tb_vga,tb_mo,tb_os
where
tb_gadget.Gadgettype_id = tb_gadgettype.Gadgettype_id
AND
tb_gadget.Department_user = tb_department.Department_id
AND
tb_gadget.Brand_tb = tb_brand.Brand_id
AND
tb_gadget.cpu_tb = tb_cpu.cpu_id
AND
tb_gadget.mb_tb = tb_mb.mb_id
AND
tb_gadget.ram_tb = tb_ram.ram_id
AND
tb_gadget.hdd_tb = tb_hdd.hdd_id
AND
tb_gadget.vga_tb = tb_vga.vga_id
AND
tb_gadget.mo_tb = tb_mo.mo_id
AND
tb_gadget.os_tb = tb_os.os_id
AND
tb_gadget.Gadget_id ORDER BY gadget_id";
$objQuery = mysql_query($strSQL);
$i = 2;
while($objResult = mysql_fetch_array($objQuery))
{
?>
<tr>
<td align="center"><?php echo $i++;?><?php echo $objResult["Gadget_id"];?> </td>
<td align="center"><?php echo $objResult["asset_com"];?></td>
<td align="center"><?php echo $objResult["Gadgettype"];?></td>
<td align="center" ><?php echo $objResult["Brand_type"];?></td>
<td align="center" ><?php echo $objResult["com_name"];?></td>
<td align="center" ><?php echo $objResult["cpu_type"];?></td>
<td align="center" ><?php echo $objResult["mb_type"];?></td>
<td align="center" ><?php echo $objResult["ram_type"];?></td>
<td align="center" ><?php echo $objResult["hdd_type"];?></td>
<td align="center" ><?php echo $objResult["vga_type"];?></td>
<td align="center" ><?php echo $objResult["asset_mo"];?></td>
<td align="center" ><?php echo $objResult["mo_type"];?></td>
<td align="center" ><?php echo $objResult["os_type"];?></td>
<td align="center" ><?php echo $objResult["license"];?></td>
<td align="center" ><?php echo $objResult["Date_purchase"];?></td>
<td align="center" ><?php echo $objResult["Gadget_user"];?></td>
<td align="center" ><?php echo $objResult["Department"];?></td>
<td align="center" ><?php echo $objResult["location"];?></td>
<td align="center" ><?php echo $objResult["Detail"];?></td>
</tr>
<?php
}
?>
<tr></tr>
</table>
</div>
<script>
window.onbeforeunload = function(){return false;};
setTimeout(function(){window.close();}, 10000);
</script>
</body>
</html>
Tag : PHP, Windows
|
ประวัติการแก้ไข 2015-01-05 14:28:05
|
|
|
|
|
Date :
2015-01-05 14:26:29 |
By :
unicorn51 |
View :
2069 |
Reply :
3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
แก้ปัญหาด้วยการใช้ ' (single quote) ข้างหน้าครับ
|
|
|
|
|
Date :
2015-01-05 14:42:23 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Date :
2015-01-06 10:15:15 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 01
|