help please.. guys this is just the only problem in my program i cant print my data from sql..i need my thesis to finish soon..help please.. heres my code

<?php

require('fpdf.php');
$fullname = "";
echo $contractno = $_REQUEST['contractno'];
echo $sname = $_REQUEST['sname'];
echo $fname = $_REQUEST['fname'];
echo $mi = $_REQUEST['mi'];
echo $dob = $_REQUEST['dob'];
echo $cpprefix = $_REQUEST['cpprefix'];
echo $cpnum = $_REQUEST['cpnum'];
echo $eadd = $_REQUEST['eadd'];

include ('connect.php');

$str = "SELECT contractno,sname,fname,mi,dob,applno,cpnum,eadd WHERE ((contractno='".$contractno."')AND (sname='".$sname."') AND (fname='".$fname."') AND (mi='".$mi."') AND (dob='".$dob."') AND (applno='".$applno.'")); 
echo $result = mysql_query($str,$db);

class PDF extends FPDF
{

        function Header()
        {
            $this->Image('lifehead.jpg',25,10,150);
            $this->SetFont('Arial','B',12);
            $this->Cell(80);
            $this->Ln(20);
        }
}
$pdf=new PDF();
$pdf->AliasNbPages();
$pdf->AddPage();
$pdf->SetFont('Arial','','8');  
//for($i=1;$i<=40;$i++)
//(x,y)
$pdf->SetXY(40,10);
$pdf->Cell(10,73,'Planholder', $sname, $fname, $mi);
//$pdf->SetXY(69,10);
//$pdf->Cell(10,73);
$pdf->SetXY(72,10); //TO INDENT
$pdf->Cell(10,73,'                                               Birthdate', $dob);
//$pdf->SetXY(136,10);
//$pdf->Cell(10,73,                                            'Contract Date');

$pdf->SetXY(40,10);
$pdf->Cell(10,95,'Contact number', $contractno);

$pdf->SetXY(42,10);
$pdf->Cell(10,110,'Application Number', $applno);
//$pdf->SetXY(69,10);
//$pdf->Cell(10,110);
$pdf->SetXY(72,10); //TO INDENT 
$pdf->Cell(10,110,'                                              Email Address', $eadd);
//$pdf->SetXY(95,10); //TO INDENT 
//$pdf->Cell(10,110,'                                              Contract Date');
$pdf->SetXY(40,10);
$pdf->Cell(10,177,'Conforme:');
$pdf->SetXY(48,10);
$pdf->Cell(10,195,'___________________');
$pdf->SetXY(56,10);
$pdf->Cell(10,202,'Planholder');
$pdf->SetXY(58,10);
$pdf->Cell(10,195,'                                              _______________');
$pdf->SetXY(66,10);
$pdf->Cell(10,202,'                                              Date');

$pdf->Output();

?>

help please.. guys this is just the only problem in my program i cant print my data from sql..i need my thesis to finish soon..help please.. heres my code

    <?php

require('fpdf.php');
$fullname = "";
echo $contractno = $_REQUEST['contractno'];
echo $sname = $_REQUEST['sname'];
echo $fname = $_REQUEST['fname'];
echo $mi = $_REQUEST['mi'];
echo $dob = $_REQUEST['dob'];
echo $cpprefix = $_REQUEST['cpprefix'];
echo $cpnum = $_REQUEST['cpnum'];
echo $eadd = $_REQUEST['eadd'];

include ('connect.php');

$str = "SELECT contractno,sname,fname,mi,dob,applno,cpnum,eadd WHERE ((contractno='".$contractno."')AND (sname='".$sname."') AND (fname='".$fname."') AND (mi='".$mi."') AND (dob='".$dob."') AND (applno='".$applno.'")); 
echo $result = mysql_query($str,$db);

class PDF extends FPDF
{

        function Header()
        {
            $this->Image('lifehead.jpg',25,10,150);
            $this->SetFont('Arial','B',12);
            $this->Cell(80);
            $this->Ln(20);
        }
}
$pdf=new PDF();
$pdf->AliasNbPages();
$pdf->AddPage();
$pdf->SetFont('Arial','','8');  
//for($i=1;$i<=40;$i++)
//(x,y)
$pdf->SetXY(40,10);
$pdf->Cell(10,73,'Planholder', $sname, $fname, $mi);
//$pdf->SetXY(69,10);
//$pdf->Cell(10,73);
$pdf->SetXY(72,10); //TO INDENT
$pdf->Cell(10,73,'                                               Birthdate', $dob);
//$pdf->SetXY(136,10);
//$pdf->Cell(10,73,                                            'Contract Date');

$pdf->SetXY(40,10);
$pdf->Cell(10,95,'Contact number', $contractno);

$pdf->SetXY(42,10);
$pdf->Cell(10,110,'Application Number', $applno);
//$pdf->SetXY(69,10);
//$pdf->Cell(10,110);
$pdf->SetXY(72,10); //TO INDENT 
$pdf->Cell(10,110,'                                              Email Address', $eadd);
//$pdf->SetXY(95,10); //TO INDENT 
//$pdf->Cell(10,110,'                                              Contract Date');
$pdf->SetXY(40,10);
$pdf->Cell(10,177,'Conforme:');
$pdf->SetXY(48,10);
$pdf->Cell(10,195,'___________________');
$pdf->SetXY(56,10);
$pdf->Cell(10,202,'Planholder');
$pdf->SetXY(58,10);
$pdf->Cell(10,195,'                                              _______________');
$pdf->SetXY(66,10);
$pdf->Cell(10,202,'                                              Date');

$pdf->Output();

?>

i just need to output Contract Number, Surname. FirstName, Mi, and The Application Number.. Ireally need this please help..thanks in advance

You should remove the echo from before your variables like

echo $contractno = $_REQUEST['contractno'];

Also, you want something like this:

$result = mysql_query($str);
while($row = mysql_fetch_array($result) {
    echo $row['eadd'];
}

The reason nothing is printing is because you are missing mysql_fetch_array and/or a while loop depending on who you want the results printed out.

I've used this class before, so below is an example of my code that I've used to get an output:

$results = $chmdb->query("SELECT * FROM " . DB . "members WHERE active = 1");

// Standard format
$pdf = new PDF_Label('5160');
$pdf->Open();

// Print labels
while($row = $results->fetch_object()) {
    $text = sprintf("%s %s\n%s %s\n%s %s, %s", "$row->first_name", "$row->last_name", "$row->address1", "$row->address2", "$row->city", "$row->state", "$row->zip");
    $pdf->Add_PDF_Label($text);
}

$pdf->Output();

Hopefully, this will set you on the right track.

tnx joshmac ill try it now..

i tried but there is an "Parse error: syntax error, unexpected T_STRING in" this error occur when i declare the while loop..wats this mean?

Can anyone please help me i have still error on my codes..i really appreciate any help cause badly i needed this to be done this eve..i need to present tomorrow..=(

<?php

require('fpdf.php');
$fullname = "";
$contractno = $_REQUEST['contractno'];
$applno = $_REQUEST['applnno'];
$sname = $_REQUEST['sname'];
$fname = $_REQUEST['fname'];
$mi = $_REQUEST['mi'];
$dob = $_REQUEST['dob'];
$cpprefix = $_REQUEST['cpprefix'];
$cpnum = $_REQUEST['cpnum'];
$eadd = $_REQUEST['eadd'];

include ('connect.php');

$sql = mysql_query("SELECT * FROM lifeplan"); 
echo $result = mysql_query("SELECT * FROM lifeplan") or die(mysql_error());
while($row = mysql_fetch_array($result)){
echo $row['sname'];
echo $row['fname'];
echo $row['mi'];
echo $row['dob'];
echo $row['contractno'];
echo $row['applnno'];
}

class PDF extends FPDF
{

    function Header()
    {
        $this->Image('lifehead.jpg',25,10,150);
        $this->SetFont('Arial','B',12);
        $this->Cell(80);
        $this->Ln(20);
    }
}
$pdf=new PDF();
$pdf->Open();
$pdf->AliasNbPages();
$pdf->AddPage();
$pdf->SetFont('Arial','','8');  
//for($i=1;$i<=40;$i++)
//(x,y)
$pdf->SetXY(40,10);
$pdf->Cell(10,73,'Planholder', $sname, $fname, $mi);
//$pdf->SetXY(69,10);
//$pdf->Cell(10,73);
$pdf->SetXY(102,10); //TO INDENT
$pdf->Cell(10,73,'Birthdate'/*, $dob*/);
//$pdf->SetXY(136,10);
//$pdf->Cell(10,73,                                            'Contract Date');

$pdf->SetXY(40,10);
$pdf->Cell(10,95,'Contact number', $contractno);

$pdf->SetXY(42,10);
$pdf->Cell(10,110,'Application Number', $applnno);
//$pdf->SetXY(69,10);
//$pdf->Cell(10,110);
$pdf->SetXY(72,10); //TO INDENT 
$pdf->Cell(10,110,'                                              Email Address', $eadd);
//$pdf->SetXY(95,10); //TO INDENT 
//$pdf->Cell(10,110,'                                              Contract Date');
$pdf->SetXY(40,10);
$pdf->Cell(10,177,'Conforme:');
$pdf->SetXY(48,10);
$pdf->Cell(10,195,'___________________');
$pdf->SetXY(56,10);
$pdf->Cell(10,202,'Planholder');
$pdf->SetXY(58,10);
$pdf->Cell(10,195,'                                              _______________');
$pdf->SetXY(66,10);
$pdf->Cell(10,202,'                                              Date');
$pdf->Output();


?>

Hi,

Try correcting your query to this

$str = "SELECT contractno,sname,fname,mi,dob,applno,cpnum,eadd WHERE ((contractno='".$contractno."')AND (sname='".$sname."') AND (fname='".$fname."') AND (mi='".$mi."') AND (dob='".$dob."') AND (applno='".$applno."'"));

actually i already did that..same theres no data only the blank page..haiszt!!! i dont know whats been missing on my codes..

I will look at your codes tomorrow. Been looking at two many codes all day.. I am pretty sure it is just a minor error. I once used this class to generate pdf, and I have never encountered such problems.

Will be right back ..

this thesis is really a misery..can anyone there kindly please help me..i feel stupid..

okey big thanks..i really appreciate it..tnx veedeoo

its really hard to be a beginner..

You should first make it easier for yourself. Make a new file and enter the info below:

<?php
require('fpdf.php');

$pdf=new PDF(); 
$pdf->Open(); 

include ('connect.php');

$str = "SELECT contractno,sname,fname,mi,dob,applno,cpnum,eadd WHERE ((contractno='".$contractno."')AND (sname='".$sname."') AND (fname='".$fname."') AND (mi='".$mi."') AND (dob='".$dob."') AND (applno='".$applno.'")); 
$result = mysql_query($str);

while($row = mysql_fetch_array($result)){ 
$row['sname']; 
$row['fname']; 
$row['mi']; 
$row['dob']; 
$row['contractno']; 
$row['applnno'];
}
$pdf->Output();
?>

If it works, then you can start adding in your other parameters ($pdf->SetXY(40,10);) between the while statement that you want to see in the output.

Hi,

Just like what Joshmac has said. You need to move few steps back for a moment and then forward if everything on the php side is confirmed to be working.

To do this, we need to check and make sure we are getting something on the screen as output from the script. Ignoring everything from the fpdf class, lets do this first.

Copy codes below and save it anyNameYouwant.php . Put this file in your localhost

<?php

  function simple_func($sql){
  ## define your database connection credentials
 $db_host = "localhost";
 $db_user = "YOUR_DATABASE USERNAME";
 $db_password = "YOUR DATABASE PASSWORD";
 $db_database ="YOUR DATABASE NAME";

 $conn = mysql_connect($db_host,$db_user,$db_password) or die(mysql_error());
 $db = mysql_select_db($db_database,$conn)  or die(mysql_error()); 
 $result = mysql_query($sql, $conn) or die(mysql_error()); 

 ## And we pulled the results 
 while($row = mysql_fetch_array( $result )) 
{
$data[] = $row;
}
## we return the data

 return $data;

 }
$text_file = "testFile.txt";
$fh = fopen($myFile, 'w') or die("can't open file");

$sql = "(SELECT * FROM lifeplan )"; 
$pdf_data = simple_func($sql);
foreach($pdf_data as $info){

$stringData = $info[1]."\n";
fwrite($fh, $stringData);

}


fclose($fh);

After running the script, it should create a text file named testFile.txt. Is the text file created? Ans: NO-> check your database creadentials and make sure they are filled in properly.. Yes-> copy codes below and run the actual pdf creator.

If you can see the actual text file created above, we need to run a second test to confirm that fpdf.php class is working on your side. Save codes below anyNameYouWant.php

<?php
 function simple_func($sql){
 ## define your database connection credentials
 $db_host = "localhost";
 $db_user = "YOUR_DATABASE USERNAME";
 $db_password = "YOUR DATABASE PASSWORD";
 $db_database ="YOUR DATABASE NAME";

 $conn = mysql_connect($db_host,$db_user,$db_password) or die(mysql_error());
 $db = mysql_select_db($db_database,$conn)  or die(mysql_error()); 
 $result = mysql_query($sql, $conn) or die(mysql_error()); 

 ## And we display the results 
 while($row = mysql_fetch_array( $result )) 
{
$data[] = $row;
}
## we return the data

 return $data;

}
$text_file = "testFile.txt";
$fh = fopen($myFile, 'w') or die("can't open file");

$sql = "(SELECT * FROM lifeplan )"; 
$pdf_data = simple_func($sql);
foreach($pdf_data as $info){

$stringData = $info[1]."\n";
fwrite($fh, $stringData);

}


fclose($fh);

## check if myFile exist
require('fpdf.php');

class PDF extends FPDF
{
function Header()
{
global $title;

// Arial bold 15
$this->SetFont('Arial','B',15);
// Calculate width of title and position
$w = $this->GetStringWidth($title)+6;
$this->SetX((210-$w)/2);
// Colors of frame, background and text
$this->SetDrawColor(0,80,180);
$this->SetFillColor(230,230,0);
$this->SetTextColor(220,50,50);
// Thickness of frame (1 mm)
$this->SetLineWidth(1);
// Title
$this->Cell($w,9,$title,1,1,'C',true);
// Line break
$this->Ln(10);
}

function Footer()
{
// Position at 1.5 cm from bottom
$this->SetY(-15);
// Arial italic 8
$this->SetFont('Arial','I',8);
// Text color in gray
$this->SetTextColor(128);
// Page number
$this->Cell(0,10,'Page '.$this->PageNo(),0,0,'C');
}

function ChapterTitle($num, $label)
{
// Arial 12
$this->SetFont('Arial','',12);
// Background color
$this->SetFillColor(200,220,255);
// Title
$this->Cell(0,6,"Chapter $num : $label",0,1,'L',true);
// Line break
$this->Ln(4);
}

function ChapterBody($file)
{
// Read text file
$txt = file_get_contents($file);
// Times 12
$this->SetFont('Times','',12);
// Output justified text
$this->MultiCell(0,5,$txt);
// Line break
$this->Ln();
// Mention in italics
$this->SetFont('','I');
$this->Cell(0,5,'(end of excerpt)');
}

function PrintChapter($num, $title, $file)
{
$this->AddPage();
$this->ChapterTitle($num,$title);
$this->ChapterBody($file);
}
}

$pdf = new PDF();
$title = 'EMPO1616 PDF FILE';
$pdf->SetTitle($title);
$pdf->SetAuthor('Jules Verne');
$pdf->PrintChapter(1,'A PDF TEST',$text_file);

$pdf->Output();

Direct your browser to the file above. Is there any pdf file created? YES -> Good you need to extend the class and modify as you want them to be. NO -> Something is wrong with your database table OR you are missing a pdf extension on your server... search google on how to enable this on your server if it is needed.

I hope this will work out well for you. I am now heading for my school, before Dr. Einstien kick me out of his class.. :)

Just to make it safe for you at school, you need to take a look at the class instantiation, so that when people ask you what just happened, you will have an idea at the least broad idea on what just have taken place in the script.

Don't hesitate to change the header function, you can always extends the class whatever you want with it. My sample codes above is the most feasible and simple.. using some of the php codes already existed and demonstrated by the author of the fpdf class author, provided us with a working template.

The text file method is a lot easier on your server, than going into the while loop and then feeding those data to the fpdf class. With the text file being created first, server resources are freed right after the text file has been created, and then the fpdf instatiation will immediately takes place.

ERRATA!

I jus realized that I made a mistake on both of the script above. Find

$fh = fopen($myFile, 'w') or die("can't open file");

And then change it to this..

$fh = fopen($text_file, 'w') or die("can't open file");

You must change it on both files the first test, and the pdf creation test.. I really have to go to school.. Let me know how did it go. I don't the chance to test the script...

hi veedeoo i tried ur script but still i got the layout page, the only problem is that data that would be generated automatically if the user input it does not appear into the file..i use fetch still it doesnt work..its me EMP01616..but thanks i appreciate the effort on helping me.. Its really bad got redefense amp! Regards to Dr Einstien..

Hi Kit005,

Can you show me your form codes where users input the data?

I will extend your regards to Dr. Einstien. He is my Physics professor. We call him Dr. Einstein, because his hair are just amazingly standing on end all the time, just like the guy in the old movie called Back to the Future ... lol.. It probably needs a truck loads of hair conditioners, before those hair will ever bow down lol .. oops ... I must have said too much already.. I hope no princeton kids are hangin around here they follow me where ever I go online... lol :)

is there a bug or what hmm i just created 3 accounts here actually..cause everyday when i tend to comment ot edit my post theres a pop up message says "sorry your not allowed to do that"..? why?

Hi there Veedeoo haiszt hard even just to simply comment in here..
i hope this would be my last account in here i have no more mailing id..this is the last one..=)

i have 3 views that the user use to encode..

HERES MY FIRST DISPLAY..

<?php
session_start();
include ('connect.php');
$sql = mysql_query("SELECT * FROM educplan WHERE contractno = '$_SESSION[contractno]'") 
or die (mysql_error());
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>SOMECONTENT</title>
<meta http-equiv="Content-Language" content="English" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script language="javascript" src="function1.js"></script>
<script language="javascript" src="checkform2.js"></script>
<link rel="stylesheet" type="text/css" href="style.css" media="screen" />
</head>

<body>
<form method="post" action="display2.php" name="myform" id="myform"  onsubmit="return checkform2()">

<div id="wrap">
<div id="header"></div>
<div id="top"> </div>
<div id="content">
<div class="articles">
<?php

//echo $contractno = $_REQUEST['contractno'];
while ($row = mysql_fetch_array($sql))
{
$sname = $row['sname'];
$fname = $row['fname'];
echo $contractno = $row['contractno'];
$mi = $row['mi'];
}
?>
                <label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<em>Surname</em></label>
<label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<em>First Name</em></label>
<label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<em>M.I.</em></label>
</div>

<div>           
<table width="660" class="table">
<tr>
<td width="116" height="22"><strong>PLANHOLDER:</strong></td>
<td width="245"><input name="sname" type="text" id="sname" value="<?php echo $sname;?>" style="color: #30C; background-color:#F3F0A9;" size="33" readonly="readonly"/></td>
<td width="245"><input name="fname" type="text" id="fname" value="<?php echo $fname;?>" style="color: #30C; background-color:#F3F0A9;" size="33" readonly="readonly"/></td>
<td width="34"><input name="mi" type="text" readonly="readonly" id="mi" value="<?php echo $mi;?>" style="color: #30C; background-color:#F3F0A9;" size="5"/></td>
</tr>
</table>
</div>

<br/>
<hr/>            
<br/>

<div class="left">
<h2><strong>UPDATE YOUR PROFILE</strong></h2>
<div>
<table width="660" class="table">
<tr>
<td width="189" ><strong>CELLPHONE NUMBER:</strong></td>
<td width="459" align="left">
<select name="cpprefix" style="color: #30C; background-color:#F3F0A9;" size="1">
  <option value="">---------------------------</option>
  <option value="GLOBE/TM">GLOBE/TM</option>
  <option value="0905">0905</option>
  <option value="0906">0906</option>
  <option value="0915">0915</option>
  <option value="0916">0916</option>
  <option value="0926">0926</option>
  <option value="0927">0927</option>
  <option value="0935">0935</option>
  <option value="0936">0936</option>
  <option value="0937">0937</option>
  <option value="0996">0996</option>
  <option value="0997">0997</option>
  <option value="SMART/TNT/RED">SMART/TNT/RED</option>
  <option value="0907">0907</option>
  <option value="0908">0908</option>
  <option value="0909">0909</option>
  <option value="0910">0910</option>
  <option value="0912">0912</option>
  <option value="0918">0918</option>
  <option value="0919">0919</option>
  <option value="0920">0920</option>
  <option value="0921">0921</option>
  <option value="0928">0928</option>
  <option value="0929">0929</option>
  <option value="0930">0930</option>
  <option value="0938">0938</option>
  <option value="0939">0939</option>
  <option value="0948">0948</option>
  <option value="0989">0989</option>
  <option value="0999">0999</option>
  <option value="SUN">SUN</option>
  <option value="0922">0922</option>
  <option value="0932">0923</option>
  <option value="0933">0933</option>
</select>
<input name="cpnum" id="cpnum" type="text" style="color: #30C; background-color:#F3F0A9;" size="20" maxlength="7"/></td>
</tr>
<tr>
<td width="189" align="left"><strong>E-MAIL ADDRESS:</strong></td>
<td width="459" align="left"><input name="eadd" id="eadd" type="text" style="color: #30C; background-color:#F3F0A9;" size="52" maxlength="50" /></td>
</tr>
<?php //} ?> 
</table>
</div>
<br />
<hr/>            
<table width="660" align="center">
<tr align="center" valign="top">
<td><input type="image" src="images/updated.jpg" name="submit" value="submit"/></td>
</tr>
</table>         
</div>
<div style="clear: both;">    </div>
</div>
<div id="bottom"> </div>
<div id="footer"> </div>
</div>
</form>
</body>
</html>

AND MY SECOND DISPLAY

<?php
session_start();
//echo $contractno = $_REQUEST['contractno'];

include ('connect.php');
echo $sql = mysql_query("SELECT * FROM educplan WHERE contractno = '$_SESSION[contractno]'") 
or die (mysql_error());
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>somethings in here</title>
<meta http-equiv="Content-Language" content="English" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" type="text/css" href="style.css" media="screen" />

<style type="text/css">
.tag {
    color: #F00;
    font-size: 12px;
    font-weight: bold;
    font-family: "Palatino Linotype", "Book Antiqua", Palatino, serif;
}
</style>
</head>

<body>
<form method="post" action="save.php" name="myform" id="myform" onsubmit="return checkform()">
<div id="wrap">
<div id="header"></div>
<div id="top"> </div>

<div id="content">
    <div class="left">
    <?php
while ($row = mysql_fetch_array($sql))
{
$sname = $row['sname'];
$fname = $row['fname'];
$mi = $row['mi'];
$dob = $row['dob'];
$contractno = $row['contractno'];
$applnno = $row['applnno'];

//$sql = mysql_query("SELECT * FROM educplan WHERE contractno = '$_SESSION[contractno]'") 
//or die (mysql_error());
?>
<h2><b>PERSONAL DATA</b></strong></h2>
             <div class="articles">
        <label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<em>Surname</em></label>
<label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<em>First Name</em></label>
<label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<em>M.I.</em></label>
            </div>

<div>           
<table width="660" class="table">
<tr>
<td width="116" height="22"><strong>PLANHOLDER:</strong></td>
<td width="245"><input name="sname" type="text" id="sname" value="<?php echo $sname;?>" style="color: #30C; background-color:#F3F0A9;" size="33" readonly="readonly"/></td>
<td width="245"><input name="fname" type="text" id="fname" value="<?php echo $fname;?>" style="color: #30C; background-color:#F3F0A9;"size="33" readonly="readonly"/></td>
<td width="34"><input name="mi" type="text" readonly="readonly" id="mi" value="<?php echo $mi;?>" style="color: #30C; background-color:#F3F0A9;" size="5"/></td>
</tr>
<tr>
<td width="116" ><strong>BIRTHDAY:</strong></td>
<td width="245" align="left"><input name="dob" type="text" readonly="readonly" id="dob" value="<?php echo $dob;?>" style="color: #30C; background-color:#F3F0A9;" size="15"/></td>
</tr>
</table>
</div>

<br/>
<hr/>
<div class="left">
<h2><strong>CONTRACT DETAILS</strong></h2>

<div>  
<table width="760" class="table">
<tr>
<td width="202" ><strong>CONTRACT NUMBER:</strong></td>
<td width="96" align="left"><input name="contractno" type="text" readonly="readonly" id="contractno" value="<?php echo $contractno;?>" style="color: #30C; background-color:#F3F0A9;" size="15"/></td>
<td width="252" align="right"><strong>APPLICATION NUMBER:</strong></td>
<td width="90" align="left"><input name="applnno" readonly="readonly" id="applnno" value="<?php echo $applnno;?>" style="color: #30C; background-color:#F3F0A9;" size="15"/></td>
</tr>
</table>
</div>
<br />
<hr/>            

<div class="left">
<h2><strong>UPDATE YOUR PROFILE</strong></h2>
<div>
<table width="660" class="table">
<tr>
<td width="189" ><strong>CELLPHONE NUMBER:</strong></td>
<td width="459" align="left"><input name="cpprefix" type="text" id="cpprefix" value="<?php echo $_POST["cpprefix"];?>" style="color: #30C; background-color:#F3F0A9;" size="8" readonly="readonly"/>&nbsp;-&nbsp;<input name="cpnum" type="text" id="cpnum" value="<?php echo $_POST["cpnum"];?>" style="color: #30C; background-color:#F3F0A9;" size="15" readonly="readonly"/></td>
<tr>
<td width="189" align="left"><strong>E-MAIL ADDRESS:</strong></td>
<td width="459" align="left"><input name="eadd" type="text" id="eadd" value="<?php echo $_POST["eadd"];?>" style="color: #30C; background-color:#F3F0A9;" size="50" readonly="readonly"/></td>
</tr>
<?php } ?>
</table>
</div>

<br />
<hr/>            

<table width="660" align="center">
<tr align="center" valign="top">
<td><input type="image" src="images/submit1.jpg" name="submit" value="submit"/></td>
</tr>
</table> 
</div>
</div>
</div>
  <div style="clear: both;"> </div>
</div>
<div id="bottom"> </div>
<div id="footer"> </div>
</div>
</form>
</body>
</html>

THAT MY SECOND VIEW WHERE THE USER UPDATED HER ACCOUNT AND THE DATA WILL BE UPDATED ON MYSQL IN THE DATABASE THEN AFTER
THAT THERE IS SOME POP UP QUESTION IF HE/SHE WANTS TO VIEW THE CERTIFICATE..IF SHE CLICKS YES THEN IT WILL CONNECT TO
THE PDF FILE WITH THE PRINTED DETAILS OF THE USER..NAME, CONTRACT # OND SOON..MY PROBLEM IS THAT THE DATA THAT WOULD BE 
SHOWN IN PDF FILE DOESNOT PRINT OR WHAT YOU CALLED BY THAT, TO THE PDF FILE ONLY THE LAYOUT OF THE WHOLE CERTIFICATE..


HERES MY connect.php the connection between the display to the database..

<?php
$db = mysql_connect("localhost","root");
   mysql_select_db("educplan",$db);

?>



Will jimmy neutron doesnt help us.. He wants us to find whats wrong with it, i stumble in web searching but
none that really fits..
Huh i wish for Santa to come along for help..=)

Hi,

I don't know about the forum's login bug, it is the admins job I think :).. I willl work on this script tomorrow..

please help me i cant able to sea the pdf it showing format error

    <?php
ob_start();
require( 'fpdf.php' );
$pdf = new FPDF();
$pdf->AddPage();
$pdf->Open();
$con = mysqli_connect( "localhost", "root", "", "my_db" );
// Check connection
if ( mysqli_connect_errno() ) {
    echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$result = mysqli_query( $con, "SELECT * FROM Persons" );

while ( $row = mysqli_fetch_array( $result ) ) {
    $fname = $row['FirstName'];
    $lname = $row['LastName'];
    $age   = $row['Age'];
    $pdf->Cell( "{$fname}" );
    $pdf->Cell( "{$lname}" );
    $pdf->Cell( "{$age}" );
}
$pdf->Output();
?>

okay big thanx.. for this code

here i'd like to share with you some C# scripts i am using to generate pdf document with easy method and powerful API controls. hope it helps you.

/// <summary>
/// create an empty PDFDocument
/// </summary>
/// <param name="pageCount"></param>
/// <returns></returns>
public PDFDocument CreatePDFDocument(int pageCount)
{
   return new PDFDocument(pageCount);
}

When I run those code I get the error below:

Fatal error: Cannot redeclare simple_func() (previously declared in C:\wamp\www\mysqltopdf\fpdf.php:36) in C:\wamp\www\mysqltopdf\fpdf.php on line 52

@athanas_1

Hi, this error happens when you declare a function two or more times. For example:

<?php

function a() {
    return ;
}

function a() {
    return ;
}

You can fix it by removing the second declaration.

Here are my codes, I dont see where I added the same function.

   <?php
   function simple_func($sql){
      ## define your database connection credentials
     $db_host = "localhost";
     $db_user = "root";
     $db_password = "";
         $db_database ="ismisdb";
         $conn = mysql_connect($db_host,$db_user,$db_password) or die(mysql_error());
     $db = mysql_select_db($db_database,$conn)  or die(mysql_error()); 
 $result = mysql_query($sql, $conn) or die(mysql_error()); 
 ## And we pulled the results 
 while($row = mysql_fetch_array( $result )) 
{
$data[] = $row;
}
## we return the data
 return $data;
  }
$text_file = "testFile.txt";
    $fh = fopen($text_file, 'w') or die("can't open file");
$sql = "(SELECT *FROM toy )"; 
$pdf_data = simple_func($sql);
foreach($pdf_data as $info){
$stringData = $info[1]."\n";
fwrite($fh, $stringData);
}
fclose($fh); 

## check if myFile exist
require('fpdf.php');
class PDF extends FPDF
{
function Header()
{
global $title;
// Arial bold 15
$this->SetFont('Arial','B',15);
// Calculate width of title and position
$w = $this->GetStringWidth($title)+6;
$this->SetX((210-$w)/2);
// Colors of frame, background and text
$this->SetDrawColor(0,80,180);
$this->SetFillColor(230,230,0);
$this->SetTextColor(220,50,50);
// Thickness of frame (1 mm)
$this->SetLineWidth(1);
// Title
$this->Cell($w,9,$title,1,1,'C',true);
// Line break
$this->Ln(10);
}
function Footer()
{
// Position at 1.5 cm from bottom
$this->SetY(-15);
// Arial italic 8
$this->SetFont('Arial','I',8);
// Text color in gray
$this->SetTextColor(128);
// Page number
$this->Cell(0,10,'Page '.$this->PageNo(),0,0,'C');
}
function ChapterTitle($num, $label)
{
// Arial 12
$this->SetFont('Arial','',12);
// Background color
$this->SetFillColor(200,220,255);
// Title
$this->Cell(0,6,"Chapter $num : $label",0,1,'L',true);
// Line break
$this->Ln(4);
}
function ChapterBody($file)
{
// Read text file
$txt = file_get_contents($file);
// Times 12
$this->SetFont('Times','',12);
// Output justified text
$this->MultiCell(0,5,$txt);
// Line break
$this->Ln();
// Mention in italics
$this->SetFont('','I');
$this->Cell(0,5,'(end of excerpt)');
}
function PrintChapter($num, $title, $file)
{
$this->AddPage();
$this->ChapterTitle($num,$title);
$this->ChapterBody($file);
}
}
$pdf = new PDF();
$title = 'EMPO1616 PDF FILE';
$pdf->SetTitle($title);
$pdf->SetAuthor('Jules Verne');
$pdf->PrintChapter(1,'A PDF TEST',$text_file);
$pdf->Output();
         ?>

The error states:

(previously declared in C:\wamp\www\mysqltopdf\fpdf.php:36) in C:\wamp\www\mysqltopdf\fpdf.php on line 52

so check the contents of included file. Also I don't know much about this code, so verify if the two functions are doing the same action or if they just have the same name.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.