Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > PHP > PHP Forum > fpdf ต้องการแสดงข้อมูลออกมาโชว์ ถ้ามีค่าเป็น NULL ให้แสดงค่า '00:00:00'



 

fpdf ต้องการแสดงข้อมูลออกมาโชว์ ถ้ามีค่าเป็น NULL ให้แสดงค่า '00:00:00'

 



Topic : 118902



โพสกระทู้ ( 21 )
บทความ ( 0 )



สถานะออฟไลน์




ใครเคยทำบ้างครับ ช่วยสอนช่วยแนะนำที

Code (PHP)
<?php session_start();?>
<html>
<head>
<title>ThaiCreate.Com PHP PDF</title>
</head>
<? include "ConnectDB/DB_Connect.php";
   include "header-engineer.php";
   include "session_login.php";
  $_SESSION['id_status'];
   $_SESSION['id_user'] = $id_user;
?>
<body>

<? 

$id = $_POST[user];
require('fpdf.php');

 
$sql_user = "SELECT jd.id_user, u.name, u.lastname FROM jobdata jd LEFT JOIN user u ON ( jd.id_user = u.id_user )  WHERE u.id_user = $_SESSION[id_user] GROUP BY name";
$result_user = mysql_query($sql_user);
$result_select = mysql_query($sql_user);


if($id!=""){
$sql_users = "SELECT jd.id_user, u.name
FROM jobdata jd
LEFT JOIN user u ON ( jd.id_user = u.id_user ) 
WHERE jd.id_user = ".$id."
GROUP BY name";
$result_user = mysql_query($sql_users);
 }//end if
$result_users = mysql_query($sql_user);

class PDF extends FPDF
{
//Load data
function LoadData($file)
{
	//Read file lines
	$lines=file($file);
	$data=array();
	foreach($lines as $line)
		$data[]=explode(';',chop($line));
	return $data;
}

//Colored table
function FancyTable($header,$data)
{
	//Colors, line width and bold font
	$this->SetFillColor(255,0,0);
	$this->SetTextColor(255);
	$this->SetDrawColor(128,0,0);
	$this->SetLineWidth(.3);
	$this->SetFont('','B');
	//Header
	$w=array(15,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12);
	for($i=0;$i<count($header);$i++)
		$this->Cell($w[$i],7,$header[$i],1,0,'C',true);
	$this->Ln();
	//Color and font restoration
	$this->SetFillColor(224,235,255);
	$this->SetTextColor(0);
	$this->SetFont('');
	//Data
	$fill=false;
	foreach($data as $row)
	{
		$this->Cell($w[0],16,$row[0],'LR',0,'C',$fill);
		$this->Cell($w[1],16,$row[1],'LR',0,'C',$fill);
		$this->Cell($w[2],16,$row[2],'LR',0,'C',$fill);
		$this->Cell($w[3],16,$row[3],'LR',0,'C',$fill);
		$this->Cell($w[4],16,$row[4],'LR',0,'C',$fill);
		$this->Cell($w[5],16,$row[5],'LR',0,'C',$fill);
		$this->Cell($w[6],16,$row[6],'LR',0,'C',$fill);
		$this->Cell($w[7],16,$row[7],'LR',0,'C',$fill);
		$this->Cell($w[8],16,$row[8],'LR',0,'C',$fill);
		$this->Cell($w[9],16,$row[9],'LR',0,'C',$fill);
		$this->Cell($w[10],16,$row[10],'LR',0,'C',$fill);
		$this->Cell($w[11],16,$row[11],'LR',0,'C',$fill);
		$this->Cell($w[12],16,$row[12],'LR',0,'C',$fill);
		$this->Cell($w[13],16,$row[13],'LR',0,'C',$fill);
		$this->Cell($w[14],16,$row[14],'LR',0,'C',$fill);
		$this->Cell($w[15],16,$row[15],'LR',0,'C',$fill);
		
		$this->Ln();
		$fill=!$fill;
	}
	$this->Cell(array_sum($w),0,'','T');
}
}

$pdf=new PDF();
//Column titles
$header=array('Name','M01','M02','M03','M04','M05','M06','M07','I01','I02','I03','I04','I05','T01','AB00','Total');
//Data loading
$row_user=mysql_fetch_array($result_user);
//*** Load MySQL Data ***//
$objConnect = mysql_connect("localhost","root","1234") or die("Error Connect to Database");
$objDB = mysql_select_db("optimizeddb");
	
$strSQL = "SELECT(SELECT name FROM user WHERE id_user= $_SESSION[id_user]) AS uname,
(SELECT SEC_TO_TIME( SUM(
TIME_TO_SEC( TIMEDIFF( timeend, timestart ) ) ) ) FROM jobdata WHERE id_type=1 AND id_user= $_SESSION[id_user]) AS T1 ,
(SELECT SEC_TO_TIME( SUM(
TIME_TO_SEC( TIMEDIFF( timeend, timestart ) ) ) ) FROM jobdata WHERE id_type=2 AND id_user= $_SESSION[id_user]) AS T2,
 (SELECT SEC_TO_TIME( SUM(
TIME_TO_SEC( TIMEDIFF( timeend, timestart ) ) ) ) FROM jobdata WHERE id_type=3 AND id_user= $_SESSION[id_user]) AS T3, 
(SELECT SEC_TO_TIME( SUM(
TIME_TO_SEC( TIMEDIFF( timeend, timestart ) ) ) ) FROM jobdata WHERE id_type=4 AND id_user= $_SESSION[id_user]) AS T4,
(SELECT SEC_TO_TIME( SUM(
TIME_TO_SEC( TIMEDIFF( timeend, timestart ) ) ) ) FROM jobdata WHERE id_type=5 AND id_user= $_SESSION[id_user]) AS T5,
(SELECT SEC_TO_TIME( SUM(
TIME_TO_SEC( TIMEDIFF( timeend, timestart ) ) ) ) FROM jobdata WHERE id_type=6 AND id_user= $_SESSION[id_user]) AS T6,
(SELECT SEC_TO_TIME( SUM(
TIME_TO_SEC( TIMEDIFF( timeend, timestart ) ) ) ) FROM jobdata WHERE id_type=7 AND id_user= $_SESSION[id_user]) AS T7,
(SELECT SEC_TO_TIME( SUM(
TIME_TO_SEC( TIMEDIFF( timeend, timestart ) ) ) ) FROM jobdata WHERE id_type=8 AND id_user= $_SESSION[id_user]) AS T8,
(SELECT SEC_TO_TIME( SUM(
TIME_TO_SEC( TIMEDIFF( timeend, timestart ) ) ) ) FROM jobdata WHERE id_type=9 AND id_user= $_SESSION[id_user]) AS T9,
(SELECT SEC_TO_TIME( SUM(
TIME_TO_SEC( TIMEDIFF( timeend, timestart ) ) ) ) FROM jobdata WHERE id_type=10 AND id_user= $_SESSION[id_user]) AS T10,
(SELECT SEC_TO_TIME( SUM(
TIME_TO_SEC( TIMEDIFF( timeend, timestart ) ) ) ) FROM jobdata WHERE id_type=11 AND id_user= $_SESSION[id_user]) AS T11,
(SELECT SEC_TO_TIME( SUM(
TIME_TO_SEC( TIMEDIFF( timeend, timestart ) ) ) ) FROM jobdata WHERE id_type=12 AND id_user= $_SESSION[id_user]) AS T12,
(SELECT SEC_TO_TIME( SUM(
TIME_TO_SEC( TIMEDIFF( timeend, timestart ) ) ) ) FROM jobdata WHERE id_type=13 AND id_user= $_SESSION[id_user]) AS T13,
(SELECT SEC_TO_TIME( SUM(
TIME_TO_SEC( TIMEDIFF( timeend, timestart ) ) ) ) FROM jobdata WHERE id_type=14 AND id_user= $_SESSION[id_user]) AS T14,
(SELECT SEC_TO_TIME( SUM(
TIME_TO_SEC( TIMEDIFF( timeend, timestart ) ) ) ) FROM jobdata WHERE id_user= $_SESSION[id_user]) AS T15";


$objQuery = mysql_query($strSQL);
$resultData = array();
for ($i=0;$i<mysql_num_rows($objQuery);$i++) {
	$result = mysql_fetch_array($objQuery);
	array_push($resultData,$result);
}
//************************//



$pdf->SetFont('Arial','',10);

//*** Table 3 ***//
$pdf->AddPage();
$pdf->Image('logo3.png',80,8,33);
$pdf->Ln(35);
$pdf->Ln();
$pdf->FancyTable($header,$resultData);

$pdf->Output("MyPDF/MyPDF.pdf","F");
?>

PDF Created Click <a href="MyPDF/MyPDF.pdf">here</a> to Download
</body>
</html>




Tag : PHP







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2015-09-16 10:14:10 By : kendocfc View : 813 Reply : 1
 

 

No. 1



โพสกระทู้ ( 1,636 )
บทความ ( 0 )



สถานะออฟไลน์
Facebook

การใช้
SEC_TO_TIME( SUM( TIME_TO_SEC( TIMEDIFF( timeend, timestart ) ) ) )


ให้ใช้
SEC_TO_TIME( SUM( UNIX_TIMESTAMP( timeend) - UNIX_TIMESTAMP( timestart )))


ยังไงก็เช็ค max min ของ SEC_TO_TIME ให้ดีด้วยนะครับ








ประวัติการแก้ไข
2015-09-16 10:54:08
2015-09-16 11:08:20
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2015-09-16 10:32:05 By : NewbiePHP
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : fpdf ต้องการแสดงข้อมูลออกมาโชว์ ถ้ามีค่าเป็น NULL ให้แสดงค่า '00:00:00'
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 00
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่