hello everyone, can you help me, i have problem with query, how i can be call query $data into $pdf, because i try to give <?php echo $data[0]['address'?>
this is my full code of Controller :
class BeasiswaController extends Controller
{
public funtion actionIndex()
}
$_nim = Yii::app()->user->name;
$_smt = Yii::app()->user->smt;
$dbCommand = Yii::app()->db->createCommand("set @sum := 0;");
$dbCommand->execute();
$sql =
// "set @sum := 0;"
"select "
. " dat_mahasiswa.nama_mhs, dat_mahasiswa.almt_mhs, dat_mahasiswa.tgl_lhr_mhs, dat_mahasiswa.tmp_lhr_mhs, tab_program_studi.nama_pst, tab_program_studi.fakultas, case(dat_mahasiswa.kd_jenis) when 'B' then 'S-2' else case (dat_mahasiswa.kd_jenis) when 'C' then 'S-1' else 'D-3' end end as jenjang,case left(dat_mahasiswa.kd_kls,1) when '0' then mid(dat_mahasiswa.kd_kls,2,1) else mid(dat_mahasiswa.kd_kls,1,2) end semt"
. " from dat_mahasiswa, tab_program_studi"
. " where dat_mahasiswa.nim_mhs='$_nim' and tab_program_studi.kd_pst = dat_mahasiswa.kd_pst;";
$dbCommand = Yii::app()->db->createCommand($sql);
$data = $dbCommand->queryAll($dbCommand);
require_once ("protected/extensions/fpdf17/fpdf.php");
$pdf=new PDF('P','mm','A4');
$pdf->AddPage();
$pdf->SetFont('Arial','',12);
$pdf->SetFont('Times','B','14');
$pdf->Cell(0,7,'','0',1,'C');
$pdf->Cell(0,1,'SURAT KETERANGAN BEASISWA','0',1,'C');
$pdf->Cell(0,0,'_________________________________','0',1,'C');
$pdf->SetFont('Times','','12');
$pdf->Cell(0,12,'Nomor: ............................................................................','0',1,'C');
$pdf->Ln();
$pdf->SetFont('Times','','12');
$pdf->Cell(0,10,'Universitas , dengan ini menerangkan bahwa:','0',1,'L');
$pdf->Cell(0,8,'','0',1,'L');
$nama = array(
array("label"=>"Nama","length"=>40, "align"=>"L"),
array("label"=>':',"length"=>5, "align"=>"L"),
array("label"=>Yii::app()->user->nama_mhs,"length"=>43, "align"=>"L"),
);
$pdf->SetFont('Times','','12');
$pdf->SetFillColor(255,255,255);
$pdf->SetTextColor(0);
$pdf->SetDrawColor(250, 235, 215);
foreach ($nama as $kolom) {
$pdf->Cell($kolom['length'], 3, $kolom['label'],0, '0', $kolom['align'], true);
}
$pdf->Cell(0,6,'','0',1,'L');
$nim = array(
array("label"=>"NIM","length"=>40, "align"=>"L"),
array("label"=>':',"length"=>5, "align"=>"L"),
array("label"=>Yii::app()->user->nim_mhs,"length"=>5, "align"=>"L"),
);
$pdf->SetFont('Times','','12');
$pdf->SetFillColor(255,255,255);
$pdf->SetTextColor(0);
$pdf->SetDrawColor(250, 235, 215);
foreach ($nim as $kolom) {
$pdf->Cell($kolom['length'], 3, $kolom['label'],0, '0', $kolom['align'], true);
}
$pdf->Cell(0,6,'','0',1,'L');
$tempat = array(
array("label"=>"Tempat/Tanggal Lahir","length"=>40, "align"=>"L"),
array("label"=>':',"length"=>5, "align"=>"L"),
array("label"=>'',"length"=>35, "align"=>"L"),
array("label"=>'/',"length"=>2, "align"=>"L"),
array("label"=>'',"length"=>5, "align"=>"L"),
);
$pdf->SetFont('Times','','12');
$pdf->SetFillColor(255,255,255);
$pdf->SetTextColor(0);
$pdf->SetDrawColor(250, 235, 215);
foreach ($tempat as $kolom) {
$pdf->Cell($kolom['length'], 3, $kolom['label'],0, '0', $kolom['align'], true);
}
$pdf->Cell(0,6,'','0',1,'L');
$alamat = array(
array("label"=>"Alamat","length"=>40, "align"=>"L"),
array("label"=>':',"length"=>5, "align"=>"L"),
array("label"=>'',"length"=>5, "align"=>"L"),
);
$pdf->SetFont('Times','','12');
$pdf->SetFillColor(255,255,255);
$pdf->SetTextColor(0);
$pdf->SetDrawColor(250, 235, 215);
foreach ($alamat as $kolom) {
$pdf->Cell($kolom['length'], 3, $kolom['label'],0, '0', $kolom['align'], true);
}
$pdf->Cell(0,14,'','0',1,'L');
$pdf->Cell(0,2,'Adalah benar yang bersangkutan adalah Mahasiswa pada:','0',1,'L');
$pdf->Cell(0,10,'','0',1,'L');
$pst = array(
array("label"=>"Program Studi","length"=>40, "align"=>"L"),
array("label"=>':',"length"=>5, "align"=>"L"),
array("label"=>'',"length"=>5, "align"=>"L"),
);
$pdf->SetFont('Times','','12');
$pdf->SetFillColor(255,255,255);
$pdf->SetTextColor(0);
$pdf->SetDrawColor(250, 235, 215);
foreach ($pst as $kolom) {
$pdf->Cell($kolom['length'], 3, $kolom['label'],0, '0', $kolom['align'], true);
}
$pdf->Cell(0,6,'','0',1,'L');
$fakultas = array(
array("label"=>"Fakultas","length"=>40, "align"=>"L"),
array("label"=>':',"length"=>5, "align"=>"L"),
array("label"=>'',"length"=>5, "align"=>"L"),
);
$pdf->SetFont('Times','','12');
$pdf->SetFillColor(255,255,255);
$pdf->SetTextColor(0);
$pdf->SetDrawColor(250, 235, 215);
foreach ($fakultas as $kolom) {
$pdf->Cell($kolom['length'], 3, $kolom['label'],0, '0', $kolom['align'], true);
}
$pdf->Cell(0,6,'','0',1,'L');
$Jenjang = array(
array("label"=>"Jenjang Pendidikan","length"=>40, "align"=>"L"),
array("label"=>':',"length"=>5, "align"=>"L"),
array("label"=>'',"length"=>5, "align"=>"L"),
);
$pdf->SetFont('Times','','12');
$pdf->SetFillColor(255,255,255);
$pdf->SetTextColor(0);
$pdf->SetDrawColor(250, 235, 215);
foreach ($Jenjang as $kolom) {
$pdf->Cell($kolom['length'], 3, $kolom['label'],0, '0', $kolom['align'], true);
}
$pdf->Cell(0,6,'','0',1,'L');
$Semester = array(
array("label"=>"Semester","length"=>40, "align"=>"L"),
array("label"=>':',"length"=>5, "align"=>"L"),
array("label"=>'',"length"=>5, "align"=>"L"),
);
$pdf->SetFont('Times','','12');
$pdf->SetFillColor(255,255,255);
$pdf->SetTextColor(0);
$pdf->SetDrawColor(250, 235, 215);
foreach ($Semester as $kolom) {
$pdf->Cell($kolom['length'], 3, $kolom['label'],0, '0', $kolom['align'], true);
}
$pdf->Cell(0,6,'','0',1,'L');
$Tahun = array(
array("label"=>"Tahun Akademik","length"=>40, "align"=>"L"),
array("label"=>':',"length"=>5, "align"=>"L"),
array("label"=>'',"length"=>5, "align"=>"L"),
);
$pdf->SetFont('Times','','12');
$pdf->SetFillColor(255,255,255);
$pdf->SetTextColor(0);
$pdf->SetDrawColor(250, 235, 215);
foreach ($Tahun as $kolom) {
$pdf->Cell($kolom['length'], 3, $kolom['label'],0, '0', $kolom['align'], true);
}
$pdf->Cell(0,10,'','0',1,'L');
$pdf->Cell(0,8,'Dengan ini kami terangkan bahwa yang bersangkutan berkelakuan baik dan belum memperoleh beasiswa','0',1,'L');
$pdf->Cell(0,2,'dari pihak manapun.','0',1,'L');
$pdf->Cell(0,10,'','0',1,'L');
$pdf->Cell(0,2,'Demikian surat keterangan ini kami buat, untuk dapat dipergunakan sebagaimana mestinya.','0',1,'L');
$pdf->Cell(0,12,'','0',1,'L');
$pdf->Cell(0,6,', ........................... ','0',1,'R');
$pdf->Cell(0,6,'a.n. Rektor ','0',1,'R');
$pdf->Cell(0,6,'Ketua Program Studi ','0',1,'R');
$pdf->Cell(0,10,'','0',1,'R');
$pdf->Cell(0,15,'.............................................. ','0',1,'R');
$pdf->Output("Beasiswa.pdf","I");
echo "PDF file is generated successfully!";
}
// Uncomment the following methods and override them if needed
/*
public function filters()
{
// return the filter configuration for this controller, e.g.:
return array(
'inlineFilterName',
array(
'class'=>'path.to.FilterClass',
'propertyName'=>'propertyValue',
),
);
}
}
Thank You Before.