?
Solved

How to print a report in php using mysql record

Posted on 2008-10-27
2
Medium Priority
?
3,237 Views
Last Modified: 2013-12-13
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,
0
Comment
Question by:lanmex
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 31

Accepted Solution

by:
Frosty555 earned 525 total points
ID: 22819279
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
 
LVL 19

Assisted Solution

by:NerdsOfTech
NerdsOfTech earned 525 total points
ID: 22839500

<?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

Featured Post

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question