|
 |
|
กดปุ่ม แล้ว link ไปที่หน้าอื่น แล้วเซฟไฟล์ที่ export จาก SQL เป็น excel พร้อมๆกันเมื่อกดปุ่ม |
|
 |
|
|
 |
 |
|
Code (PHP)
<script src="js/jquery-1.4.1.min.js" type="text/javascript"></script> // หาโหลดเอาคับ พิม jquery ใน google
<?
include ("connect_db.inc.php");
$code = 'A0001';
$sql = " SELECT time FROM tabel WHERE code = $code ";
$query = mysql_query($sql);
$rw = mysql_fetch_array($query);
?>
<input type="submit" name="btn_ok" id="btn_ok" value="OK">
<input type="hidden" name="value" id="value" value="<?=$rw['code']?>" />
Code (JavaScript)
$(function(){
$("#btn_ok").live('click', function(){
export_excel ();
});
});
function export_excel (){
var cuscode = $("#value").val();
if(cuscode!=''){
$.ajax({
type: "POST",
url: "update_order.php",
data: "value="+cuscode,
success: function(data){
}else{
alert('ไม่สามารส่งข้อมูลได้');
}
}
Code (PHP)
<?php
header("Content-Type: application/vnd.ms-excel");
header('Content-Disposition: attachment; filename="stocklist.xls"');#ชื่อไฟล์
?>
<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">
<HTML>
<HEAD>
<meta http-equiv="Content-type" content="text/html;charset=windows-874" />
</HEAD><BODY>
<?
include "config/config.inc.php";
$cusocde = $_REQUEST['value'];
$where = " Where cuscode ='".$cusocde."' ";
$sql_rows = "Select * FROM table $where ";
$sql = mysql_query($sql_rows);
?>
<table x:str BORDER="1">
<tr align="center" bgcolor="#e0e4e8">
<td width="10%" nowrap="nowrap" bgcolor="#e0e4e8" >รหัส</td>
<td width="40%" nowrap="nowrap" bgcolor="#e0e4e8" >ลูกค้า</td>
</tr>
<?
if(mysql_num_rows($sql)){
$color = 1;
$i=1;
while($rw = mysql_fetch_array($sql)){
$i++;
$bgr = ($color=($color+1)%2) ? '#EBEDF1' : '#FFFFFF';
?>
<tr valign="top" bgcolor="<?=$bgr?>" onMouseOver="bgr_color(this, '#FFCC99')" onMouseOut="bgr_color(this, '<?=$bgr?>')">
<td align="center" valign="middle" nowrap="nowrap" ><div align="left"><?=$rw['cuscode']?></div></td>
<td align="center" valign="middle" nowrap="nowrap" ><div align="left"><?=$rw['cusname']?></div></td>
</tr>
<? } }else{?>
<tr valign="top" bgcolor="<?=$bgr?>" onMouseOver="bgr_color(this, '#FFCC99')" onMouseOut="bgr_color(this, '<?=$bgr?>')">
<td colspan="4" align="center" valign="middle" nowrap="nowrap" >ไม่มีข้อมูล</td>
</tr>
<? }?>
</table>
</BODY>
</HTML>
|
ประวัติการแก้ไข 2011-05-05 16:34:22
 |
 |
 |
 |
Date :
2011-05-05 16:30:44 |
By :
puchong1 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 03
|