How to print a report in php using mysql record

Hi all,

I have a database in MySQL and an entry form in php, users are already using the entry form, now I need to print a report in landscape,

the fileds I need to print are for example Name, Lastname, Birthday and description,

Can you guys give an example to do that, this is the first time I'm going to make a report in php.

Thank you guys,
lanmexAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Frosty555Commented:
PHP doesn't directly support a "reporting" mechanism. It's only job is to process data behind the scenes, and then output HTML to the client browser, which renders it on the screen for the user.

So you would create a PHP page which grabbed the data from the mysql database and output HTML that layed out the data the way you want your report to look. It would then be up to the user to print it out. And exactly how it looked would depend on that person's browser, OS, printer etc.

You can also try using the FPDF library to generate a PDF in PHP, and then send the PDF to the user, but generating a PDF from scratch by drawing every block of text, and every line and box... is very tedious.

http://www.fpdf.org/
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
NerdsOfTechTechnology ScientistCommented:

<?php
mysql_connect (DB_HOST, DB_USER, DB_PASSWORD); // replace with your mySQL information
 
mysql_select_db (DB_NAME);
 
$query = "SELECT Name, LastName, Birthday, Description FROM TableName"; // replace table name with actual table name
 
$result = mysql_query($query) or die(mysql_error());
$num=mysql_numrows($result);
       
// Print out the contents of each row into a table 
?>
<table>
<tr>
<td>Name</td>
<td>LastName</td>
<td>Birthday</td>
<td>Description</td>
</tr>
<?
while($row = mysql_fetch_array($result)){
   echo "<tr>\n";
   echo "<td>$row['Name']</td>\n";
   echo "$row['LastName']</td>\n";
   echo "$row['Birthday']</td>\n";
   echo "$row['Description']</td>\n";
   echo "</tr>\n";
}
?>
</table>

Open in new window

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.