 |
|
เปิดที่ Microsoft Office Excel 2007 บ้างเครื่องไม่เป็นภาษาไทย
Code (PHP)
<?
$student_altitude =$_GET['student_altitude'];
$student_room =$_GET['student_room'];
header('Content-type: application/csv');
header('Content-Disposition: attachment; filename="testing.xls"');
//echo "<meta http-equiv='refresh' Content-Disposition: attachment; filename='testing.csv'>" ;
$student_altitude =$_GET['student_altitude'];
$student_room =$_GET['student_room'];
include("connecthost2545.php") ;
mysql_connect( $hostname,$username,$password) or die ("ไม่สามาติดต่ด Mysq ได้ ");
mysql_select_db($dbname) or die("ไม่สารถเลือกฐานข้อมูลได้");
mysql_query("SET NAMES UTF8");
echo "เลขที่,เลขประจำตัว,ชื่อ,สกุล,\n";
$sql = "SELECT * FROM student where student_altitude ='$student_altitude' and student_room='$student_room' and student_sex='M' ORDER BY `student`.`id_student` ASC ";
$dbquery = mysql_query($sql);
$num_rows = mysql_num_rows($dbquery);
$i=0;
while ($i < $num_rows)
{
$result= mysql_fetch_array($dbquery);
$ilo++;
echo "$ilo,$result[id_student],เด็กชาย$result[student_name],$result[student_familyname],\n";
$i++;
}
$sql = "SELECT * FROM student where student_altitude ='$student_altitude' and student_room='$student_room' and student_sex='F' ORDER BY `student`.`id_student` ASC ";
$dbquery = mysql_query($sql);
$num_rows = mysql_num_rows($dbquery);
$i=0;
while ($i < $num_rows)
{
$result= mysql_fetch_array($dbquery);
$ilo++;
echo "$ilo,$result[id_student],เด็กหญิง$result[student_name],$result[student_familyname],\n";
$i++;
}
mysql_close(); ?>
|
 |
 |
 |
 |
Date :
2011-09-22 14:45:36 |
By :
item170 |
|
 |
 |
 |
 |
|
|
 |