|
|
|
คืออยากให้เรียงรหัสจากฐานข้อมูลค่ะคือต้องเรียงค่าอย่างไรค่ะ |
|
|
|
|
|
|
|
Code (PHP)
?php
define('FPDF_FONTPATH','font/');
require('fpdf.php');
$pdf=new FPDF();
$pdf->AddFont('angsana','','angsa.php');
$pdf->SetMargins( 40,10,30);
$pdf->AddPage();
$pdf->SetFont('angsana','',14);
include "connect.php";
mysql_select_db($dbname,$m)or die("Can not Choose DATABASE ?????").mysql_error();
mysql_query("SET NAMES UTF8");
/*$Geo = $_GET[ddlGeo];
$object = $_GET[ddlobject];
$t = $_GET[ddlobject];
$room = $_GET[ddlobject];*/
$strSQL = "SELECT * FROM student WHERE room = '$ddlroom' and object = '$ddlobject' and faculty = '$ddlGeo' order by id_student ASC";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
$Num_Rows = mysql_num_rows($objQuery);
$strSQL1= "SELECT * FROM faculty WHERE id_faculty = '$ddlGeo'";
$objQuery1 = mysql_query($strSQL1) or die ("Error Query [".$strSQL1."]");
$objResult1 = mysql_fetch_array($objQuery1);
$faculty1 = $objResult1["faculty"];
$strSQL2= "SELECT * FROM fix_object WHERE id_object = '$ddlobject'";
$objQuery2 = mysql_query($strSQL2) or die ("Error Query [".$strSQL2."]");
$objResult2 = mysql_fetch_array($objQuery2);
$object1 = $objResult2["object1"];
$strSQL3= "SELECT * FROM room WHERE id_room = '$ddlroom'";
$objQuery3 = mysql_query($strSQL3) or die ("Error Query [".$strSQL3."]");
$objResult3 = mysql_fetch_array($objQuery3);
$room = $objResult3["room"];
$pdf->Cell( 0 , 6 , iconv( 'UTF-8','cp874' , 'คณะ '.$faculty1.'สาขา '.$object1.'ห้อง ' .$room) , 0 , 1 , 'C' );
/*if($status==1&&$room<>'')
{*/
$pdf->Cell( 0 , 6 , iconv( 'UTF-8','cp874' , 'แสดงรายชื่อนักศึกษา' ) , 0 , 1 , 'C' );
$pdf->Cell( 10 , 6 , iconv( 'UTF-8','cp874' , 'ลำดับ' ), 1,0,'C');
$pdf->Cell( 30 , 6 , iconv( 'UTF-8','cp874' , 'รหัส' ), 1,0,'C');
$pdf->Cell( 50 , 6 , iconv( 'UTF-8','cp874' , 'ชื่อ-นามสกุล' ), 1,0,'C');
$pdf->Cell( 30 , 6 , iconv( 'UTF-8','cp874' , 'รหัสผ่าน' ), 1,0,'C');
$pdf->Ln();
$sql="SELECT * FROM student WHERE room = '$ddlroom' and object = '$ddlobject' and faculty = '$ddlGeo'";
$result=mysql_query($sql,$m)or die("Can not SELECT into DATABASE ???!").mysql_error();
while($row=mysql_fetch_array($result))
{
$sql2="SELECT*FROM login WHERE id_user='$row[id_student]'";
$result2=mysql_query($sql2,$m)or die("ไม่สามารถเลือกฐานข้อมูลได้").mysql_error();
$rs3=mysql_fetch_array($result2);
$num = $num+1;
$pdf->Cell( 10 , 6 , iconv( 'UTF-8','cp874' , $num), 1,0,'C');
$pdf->Cell( 30 , 6 , iconv( 'UTF-8','cp874' , $rs3[id_user]), 1,0,'C');
$pdf->Cell( 50 , 6 , iconv( 'UTF-8','cp874' , $row[title_name].' '.$row[name_stu].' '.$row[lastname_stu] ), 1,0,'L');
$pdf->Cell( 30 , 6 , iconv( 'UTF-8','cp874' , $rs3[pass_user]), 1,0,'C');
/* $id = $row[idstd];
$sql2="SELECT * FROM student WHERE room = '$ddlroom' and object = '$ddlobject' and faculty = '$ddlGeo'";
$result2=mysql_query($sql2,$m)or die("Can not SELECT into DATABASE ???!").mysql_error();
$rs=mysql_fetch_array($result2);
$idAct = $rs[idAct];
$sql3="SELECT * FROM student WHERE room = '$ddlroom' and object = '$ddlobject' and faculty = '$ddlGeo'";
$result3=mysql_query($sql3,$m)or die("Can not SELECT into DATABASE ???").mysql_error();
$rs3=mysql_fetch_array($result3);
$pdf->Cell( 30 , 6 , iconv( 'UTF-8','cp874' , $rs3[actName] ), 1,0,'L');*/
$pdf->Ln();
}
mysql_close($m);
$pdf->Output();
?>
คืออยากให้เรียงจากรหัสนักศึกษาค่ะ
Tag : PHP, MySQL
|
ประวัติการแก้ไข 2011-03-28 13:06:05
|
|
|
|
|
Date :
2011-03-28 12:49:36 |
By :
deedee2338 |
View :
706 |
Reply :
4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
order by ฟิลรหัสหนักศึกษา asc หรือ desc
ASC น้อยไปมาก
DESC มากไปน้อย
|
|
|
|
|
Date :
2011-03-28 13:02:41 |
By :
avsqlz |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ใส่แล้วแต่ไม่ได้
|
|
|
|
|
Date :
2011-03-28 13:05:09 |
By :
deedee2338 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ฟิลรหัสหนักศึกษา เก็บเป็น int หรือเปล่าครับ
|
|
|
|
|
Date :
2011-03-28 13:18:23 |
By :
avsqlz |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ได้แล้วค่ะคือใส่ผิดที่ค่ะ
|
|
|
|
|
Date :
2011-03-28 14:41:52 |
By :
deedee2338 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 03
|