473,396 Members | 1,927 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Report writing in PHP - what tools for making formating nice?

Hi there,

A client of mine wants to start generating some reports from their PHP /
MYSQL database.

They were previously gathering data from the screen and cutting and pasting
it into a Word document template. They now just want to generate it.

My initial thoughts are to just format the information in a table and then
they print it out. But due to the dynamic nature of the reports and what is
included, there might be issues with regard to the width fitting on a piece
of paper, and the general format will not look as good as a Word document
would.

What ways could I approach this problem? Is there anything available which
would make report formatting attractive and easy?

Thanks in advance.

Kind regards

Dave
Nov 3 '05 #1
6 4690
NC
Dave Smithz wrote:

A client of mine wants to start generating some reports from their PHP /
MYSQL database.

They were previously gathering data from the screen and cutting and pasting
it into a Word document template. They now just want to generate it.

My initial thoughts are to just format the information in a table and then
they print it out. But due to the dynamic nature of the reports and what is
included, there might be issues with regard to the width fitting on a piece
of paper, and the general format will not look as good as a Word document
would.

What ways could I approach this problem? Is there anything available which
would make report formatting attractive and easy?


You can generate reports in either PDF or RTF.

The exact approach to generating PDF would depend on what PDF
generation tool(s) you use. There are at least two PDF generation
extensions bundled with PHP; there are also "pure PHP" tools such as
FPDF that are somewhat slower, but do not require any particular PHP
extension to be available (helpful for hosted applications).

If you want to use RTF (which is readable by most word processors)
instead, take a look here:

http://groups.google.com/group/alt.p...914bd0d0a120fc

This is my old post to alt.php where I show how to build a simple
"report" (actually, a set of mailing labels) without having to learn a
lot about RTF.

Cheers,
NC

Nov 3 '05 #2
Dave Smithz wrote:

<snip>

My initial thoughts are to just format the information in a table and then
they print it out. But due to the dynamic nature of the reports and what
is included, there might be issues with regard to the width fitting on a
piece of paper, and the general format will not look as good as a Word
document would.

Three letters: CSS
What ways could I approach this problem? Is there anything available which
would make report formatting attractive and easy?


You could do all sorts of things to make it look fancy in print.....but why?
Yes, we all know people for whom an Email isn't real unless its in black
and white on A4 - even if its spam. But choosing this as your starting
point reinforces this kind of behaviour instead of solving it.

PDF is better, but instead of dead tree - it's dead data. An HTML table
(yes, I do mean table - I know you can create fancy layouts with CSS and
don't need tables to do it but....) can be imported back into a
spreadshseet or a PHP array.

Don't kill your data - give it a nice new home!

C.

Nov 3 '05 #3
Dave Smithz wrote:
My initial thoughts are to just format the information in a table and then
they print it out. But due to the dynamic nature of the reports and what is
included, there might be issues with regard to the width fitting on a piece
of paper, and the general format will not look as good as a Word document
would.


Try using point sizes to specify the dimensions of the table cells. A
point is 1/72 of an inch. If you specify the width of a table to be
468pt, then in theory, the browser would print it out at exactly 6.5
inches. CSS gives you a lot of control over the appearance, but there's
no guarantee of WYSIWYG.

Nov 4 '05 #4
Thanks for the comments. I have been reading more and at first I thought the
RTF file generation would be perfect.

The reason why CSS is not suitable is because I need to generate these
reports into a format that is sent back to clients. They need them in a
particualr format and I could not really mess around with CSS trying to get
it write. Plus they want to be sent a file via email or hard copy so RTF or
PDF would be easier.

On reading up I thought RTF would be great because of the dynamic nature of
the required reports. I could create an RTF document template with a table
in it. Look how a new table row is created. And for each table row I want to
add to the report, just add the necessary RTF commands and fill it with
data.

However looking at an RTF document in raw text and working out how to add a
new table line with data does not seem stright forward. I do not really
fancy spending a lot of time learning about RTF.
I did try and save Word document in XML format. This might be easier to
figure out how to add new lines to a table and populate the table with
report data. I can assume my clients are using Word 2003 so they would be
able to read these document (worse case I could print them out as PDF before
sending).

I think I am going the right way about this but any other suggestions or
ways to make adding a line to the XML or RTF would be welcome.

Kind regards

Dave
Nov 7 '05 #5
Hmmm,
Even playing around with the XML strucutre although I managed to create
another row by editing the raw text, when I think about it, I Also have
dynamic anount of columns in the report depedning on what is needed to be
generated. Having to learn and create functions that handle the dynamic
generation of the correct XML (therefore the correct amount of columns and
the amount of rows) might make things a bit tricky.

Opoen to other easier ways of approaching this. Maybe for now it will just
be printer HTML tables but I just do not think my clients will be happy with
this.

Kind regards

Dave
Nov 7 '05 #6
Can you just make a file in Word and then just export the data to a
file that Word will read? Kind of like when you are doing envelopes
and labels setup? This way you can layout the whole thing the way you
have been in word and the text document will import the exported file
and look exactly how it has in the past...

Just a suggestion.

-Rick

--------------------------
Looking for a place to go to happy hour tonight? Check out
HappyHourHotSpots.com!

Nov 7 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Peter Simpson | last post by:
Hello everybody. I'm trying to set up a simple web interface to maintain the rules configuration for Shorewall. This entails writing to at least one of several root-owned files in...
1
by: Sean Pau | last post by:
I would like my user to retrieve SQL data through intranet website: 1. Go to intranet link and enter parameters for report (for example Order From and To date) 2. Click on "Run" button and the...
3
by: FeveZ | last post by:
I've been stuck on a problem now for ages and i'm about ready to pack my project in because of it lol. OK here is my scenario. I have an existing Crystal Report, which I have added to my...
4
by: jaYPee | last post by:
I have a report created in crystal report. My problem is on how can I remove the decimal point without converting the value. say for example if I have this data: Unit 2 1.5 2 3
6
by: Bob Alston | last post by:
I am looking for Access reporting add-in that would be easy to use by end users. My key focus is on selection criteria. I am very happy with the Access report writer capabilities. As far as...
2
by: jmar | last post by:
I am updating a VB4.0 quote generation program to VB.net. The old program takes user inputs, performs calculations, saves the data to Access databases and uses Crystal Reports 5.0 to generate a...
10
by: John Dann | last post by:
I'm writing a VB2005 program that needs to generate some printed output, including a main table. At present I'm doing this output simply as a text file, which works well enough to allow printing...
2
by: sitko | last post by:
Hi, I'm in the process of converting a VB.net program into a C program so it can run on a unix like machine. I've been moving along at a nice pace, but this conversion has stumped me. I need...
1
by: Doug | last post by:
What is the simplest way to make a report where only the records where a field matches a certain date are included, and the user first selects that date (from form or popup)? (I can write the SQL...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.