Header() ของ fpdf ไม่แสดงค่าของตัวแปรที่รับมาจากลิ้งค์

ถาม-ตอบ แนะนำไอเดียว โค้ดตัวอย่าง แนวทาง วิธีแก้ปัญหา Header() ของ fpdf ไม่แสดงค่าของตัวแปรที่รับมาจากลิ้งค์

Header() ของ fpdf ไม่แสดงค่าของตัวแปรที่รับมาจากลิ้งค์
$year       =$_GET['year'];
 
function Header()
{
 
$this->Image('images/logo1.jpg',88,8,33);
 
$this->Cell(80);
 
$this->Cell(27,50,iconv('UTF-8', 'cp874',"รายชื่อนักเรียน"),0,0,'C');
$this->Cell(-40,60,iconv('UTF-8', 'cp874',"ปีการศึกษา $year"),0,0,'C');
 
$this->Ln(40);
}

มันไม่แสดงตัวแปร $year ครับ ช่วยหน่อยนะครับ
 


Suthon77 202.129.29.xxx 16-05-2018 16:07:51

คำแนะนำ และการใช้งาน

สมาชิก กรุณา ล็อกอินเข้าระบบ เพื่อตั้งคำถามใหม่ หรือ ตอบคำถาม สมาชิกใหม่ สมัครสมาชิกได้ที่ สมัครสมาชิก


  • ถาม-ตอบ กรุณา ล็อกอินเข้าระบบ
  • เปลี่ยน


    ( หรือ เข้าใช้งานผ่าน Social Login )

 ความคิดเห็นที่ 1
ทดสอบฟิกค่าไปแทนการส่งค่าดูว่า ข้อความแสดงปกติไหม ถ้าค่าที่ไม่ได้่ส่งมาปกติ ก็น่าจะเป็นที่การส่งค่า
ตรวจสอบชื่อตัวแปร หรือเปลี่ยนเป็นชื่อตัวแปรอื่นแทน เพือหาสาเหตุ


ninenik 223.24.183.xxx 17-05-2018
 ความคิดเห็นที่ 2
ถ้ากำหนดค่าโดยตรง มันแสดงข้อมูลได้ครับ แต่พอส่งค่าไปจากลิ้งค์ มันไม่แสดง


suthon77 202.129.29.xxx 17-05-2018 09:00
 ความคิดเห็นที่ 3
<?php
require('../fpdf/fpdf.php');
require_once('config.inc.php'); 
require_once('../include/functions/functions.php');
ConnectDB();
$year       =$_GET['year'];
$term       =$_GET['term'];
$class      =$_GET['class'];
$scout_id =$_GET['scout_id'];
 
if($scout_id=='1'){
$scout= 'ลูกเสือเสนา';
  }else  if($scout_id=='2'){
$scout= 'ลูกเสืออากาศ';
  }else  if($scout_id=='3'){
$scout= 'เนตรนารี';
  }else  if($scout_id=='4'){
$scout= 'ยุวกาชาด';
  }else  if($scout_id=='5'){
$scout= 'บำเพ็ญประโยชน์';
  }else  if($scout_id=='6'){
$scout= 'เนตรนารีอากาศ';
  }
  
$condition="and r.class='$class' and  r.year='$year' and r.semester='$term' and s1.scout_id='$scout_id' ";
 
$strSQL = "select * from register r,scout_student s1 where r.student_id=s1.student_id  $condition  
order by r.class,r.room,r.no ASC";
$objQuery = mysql_query($strSQL) or die(mysql_error());
 
class PDF extends FPDF
{
 
function Header()
{
 
$this->Image('images/logo1.jpg',88,8,33);
 
$this->Cell(80);
//Title ส่วนที่ไม่แสดงข้อมูล
$this->Cell(27,50,iconv('UTF-8', 'cp874',"รายชื่อนักเรียนกิจกรรม".$scout),0,0,'C');
$this->Cell(-40,60,iconv('UTF-8', 'cp874',"ปีการศึกษา ".$term.'/'.$year),0,0,'C');
 
$this->Ln(40);
}
 
function LoadData($file)
{
$lines=file($file);
$data=array();
foreach($lines as $line)
$data[]=explode(';',chop($line));
return $data;
}
 
//Simple table
function BasicTable($header,$data)
{
$w=array(10,20,140,20);
for($i=0;$i<count($header);$i++)
$this->Cell($w[$i],7,iconv('UTF-8', 'cp874', $header[$i]),1,0,'C');
$this->Ln();
 
foreach ($data as $eachResult) 
{
  $s++;
$rs=selectRecord("student","where student_id='$eachResult[student_id]' ");
extract($rs);
$this->Cell(10,6,$s,1,0,'C');
$this->Cell(20,6,$eachResult["student_id"],1,0,'C');
$this->Cell(140,6,iconv('UTF-8', 'cp874',$rs['sex'].$rs["name"]),1);
$this->Cell(20,6,$eachResult["class"].'/'.$eachResult['room'],1,0,'C');
 
 
$this->Ln();
}
}
 
}
 
$pdf=new PDF();
//Column titles
$header=array('ลำดับ','รหัสประจำตัว','ชื่อ-นามสกุล','ระดับชั้น');
//Data loading
 
//*** Load MySQL Data ***//
 
 
if($scout_id=='1'){
$scout= 'ลูกเสือเสนา';
  }else  if($scout_id=='2'){
$scout= 'ลูกเสืออากาศ';
  }else  if($scout_id=='3'){
$scout= 'เนตรนารี';
  }else  if($scout_id=='4'){
$scout= 'ยุวกาชาด';
  }else  if($scout_id=='5'){
$scout= 'บำเพ็ญประโยชน์';
  }else  if($scout_id=='6'){
$scout= 'เนตรนารีอากาศ';
  }
  
$condition="and r.class='$class' and  r.year='$year' and r.semester='$term' and s1.scout_id='$scout_id' ";
 
$strSQL = "select * from register r,scout_student s1 where r.student_id=s1.student_id  $condition  
order by r.class,r.room,r.no ASC";
$objQuery = mysql_query($strSQL) or die(mysql_error());
 
$resultData = array();
for ($i=0;$i<mysql_num_rows($objQuery);$i++) {
$result = mysql_fetch_array($objQuery);
array_push($resultData,$result);
}
//************************//
$pdf->AddFont('angsana','','angsa.php');
$pdf->SetFont('angsana','',14);
 
 
$pdf->Ln(10);
 
$pdf->AddPage();
//$pdf->Image('logo.png',80,8,33);
$pdf->BasicTable($header,$resultData);
$pdf->Output();
 
?>
 


suthon77 202.129.29.xxx 17-05-2018 15:24
 ความคิดเห็นที่ 4
  หลักๆ ก็น่าจะตรวจสอบการส่งค่า เช็คว่ามีการส่งค่ามาไหม ส่วนตรงที่เรียกใช้งาน เป็นได้รวมค่าเก็บไว้ในตัวแปรหนึ่งก่อน
แล้วเรียกใช้ผ่านตัวแปรอีกที เพราะไม่แน่ใจว่า การไปทำคำสังรวมหรือต่อค่าตัวแปร ในส่วนนั้นมีผลให้ไม่แสดงไหม


ninenik 223.24.156.xxx 17-05-2018
 ความคิดเห็นที่ 5
แสดงค่าตัวแปรได้แล้วครับ คือเรียกตรงๆจาก GET['year'] เลย
$this->Cell(27,50,iconv( 'UTF-8','TIS-620','ปีการศึกษา '.$_GET['term'].'/'.$_GET['year']),0,0,"C");
ขอบคุณมากครับ



suthon77 202.129.29.xxx 18-05-2018 11:37
1






เว็บไซต์ของเราให้บริการเนื้อหาบทความสำหรับนักพัฒนา โดยพึ่งพารายได้เล็กน้อยจากการแสดงโฆษณา โปรดสนับสนุนเว็บไซต์ของเราด้วยการปิดการใช้งานตัวปิดกั้นโฆษณา (Disable Ads Blocker) ขอบคุณครับ