السلام عليكم
اخواني يوجد في الكلاس تصدير ملف pdf برسم بياني
على رابط موقعهم الكود http://www.tecnick.com/pagefiles/tcpdf/example_031.phps
انا اريد جلب قيم من قاعدة البيانات
كود المثال الذي في الموقع ويعمل 100%
كود PHP:
<?php
require_once('../config/lang/eng.php');
require_once('../tcpdf.php');
// create new PDF document
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
// set document information
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('Nicola Asuni');
$pdf->SetTitle('TCPDF Example 031');
$pdf->SetSubject('TCPDF Tutorial');
$pdf->SetKeywords('TCPDF, PDF, example, test, guide');
// disable header and footer
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);
//set margins
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
//set auto page breaks
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
//set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
//set some language-dependent strings
$pdf->setLanguageArray($l);
// set font
$pdf->SetFont('helvetica', '', 14);
// add a page
$pdf->AddPage();
$xc = 105;
$yc = 55;
$r = 40;
$pdf->SetFillColor(120, 120, 255);
$pdf->PieSector($xc, $yc, $r, 20, 120);
$pdf->SetFillColor(120, 255, 120);
$pdf->PieSector($xc, $yc, $r, 120, 250);
$pdf->SetFillColor(255, 120, 120);
$pdf->PieSector($xc, $yc, $r, 250, 20);
//Close and output PDF document
$pdf->Output('example_031.pdf', 'I');
?>
كود جلب البيانات من القاعدة و لكن لم يعمل معي
كود PHP:
<?php
$host="localhost"; // Host name
$username="root"; // Mysql username
$password=""; // Mysql password
$db_name="m1"; // Database name
$tbl_name="ho"; // Table name
// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
// get value of id that sent from address bar
$id = $_GET["id"];
$sql="SELECT * FROM $tbl_name WHERE id='$id'";
$result=mysql_query($sql);
$num = mysql_num_rows($result);
require_once('../config/lang/eng.php');
require_once('../tcpdf.php');
// create new PDF document
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
// set document information
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('Nicola Asuni');
$pdf->SetTitle('TCPDF Example 031');
$pdf->SetSubject('TCPDF Tutorial');
$pdf->SetKeywords('TCPDF, PDF, example, test, guide');
// disable header and footer
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);
//set margins
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
//set auto page breaks
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
//set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
//set some language-dependent strings
$pdf->setLanguageArray($l);
while($rows=mysql_fetch_array($result)){
$data1 = $rows['number'];
$data2 = $rows['nulas'];
// set font
$pdf->SetFont('helvetica', '', 14);
// add a page
$pdf->AddPage();
$xc = $data1;
$yc = $data2;
$pdf->SetFillColor(120, 120, 255);
$pdf->PieSector($xc, $yc, 20, 120);
$pdf->SetFillColor(120, 255, 120);
$pdf->PieSector($xc, $yc, 120, 250);
}
//Close and output PDF document
$pdf->Output('example_031.pdf', 'I');
?>
انا اريد جلب قيمتان فقط