Page 1 of 1

printing php reports & multiple comps. for one app.

Posted: Wed Aug 10, 2011 7:49 am
by aashish_2025
First of all I'm a nebie in both php and web application development and so, I'm having tonnes of problems on that.

Actually, I'm building a "Marksheet Generation" application where you enter the marks of various students(like in excel) and then you get individual mark-sheets(summary of all the marks in all the subjects). However, I have a lots of questions for that.

First of all, I want to develop the report(mark-sheet) as an image(any format). What I've done actually is, in a page, you get to choose a student and then after following the student's link, you go to another page where you have all his info and marks retrieved from the database. So, I've used HTML for building the report card and it works perfectly fine. But I want the report to be as an image. So, is there any way I can do that?

The next thing is I need to print the report(mark-sheet) and I can't figure out a way to print the entire page(that's why I want the report to be an image :) )So, how can I print the entire page(report).

Another thing bothering me is, I need to mass-print the reports(for example, print all the reports of a particular school/class) So is there something like batch-processing to do that? I mean to print all the reports after one command!

The next thing is can users use the same application to enter data from multiple computers? I mean, for example this is the server where the application is hosted(I use wamp by the way) and all the client computers are connected to this one. So, can the software be used remotely(from another computer)? I've heard that for VB.NET and other platforms, you need to work to make that possible, but I suppose in PHP, you don't have to spare any more hard work to do that. Is that true? If that's true, won't there be some problem when more than one user is using the same database(and in fact the same table) to enter and access the data, something like a sharing violation? And, how can I prevent data redundancy in such cases?

So, these are some of the problems I'm getting and I expect help from you guys! Hope you people will help!

Hoping for some reply!

Re: printing php reports & multiple comps. for one app.

Posted: Thu Aug 11, 2011 1:12 am
by McInfo
aashish_2025 wrote:[...]report(mark-sheet) as an image[...]
You might create the image from scratch using one of PHP's Image Processing and Generation extensions.

On Windows, PHP's GD extension offers an imagegrabwindow() function that might or not be practical. Converting your existing HTML page into an image would involve opening a browser on the server and taking a screen capture of the window; then maybe cropping the image. See the example in the manual.

However, I am not sure what advantage an image has over HTML/CSS. Scale-to-fit, maybe?
aashish_2025 wrote:[...]print the entire page[...]
If you mean print to a printer connected to the client, that would require user action, meaning the user clicks File > Print.

If you mean print to a printer connected to the server, you can try the Printer extension (Windows-only).

Printing is a process that requires some oversight. The paper tray could run empty. The ink/toner could run low. Paper could jam. The printer might be unplugged...
aashish_2025 wrote:[...]mass-print the reports[...]
This suggestion does not apply to the image idea: There are CSS properties for setting page breaks, so all the printable pages could be on one HTML page.

If you are printing server-side, you should be able to send multiple print jobs programmatically.
aashish_2025 wrote:[...]enter data from multiple computers[...]
Yes. That is the strength of server programming. The firewall must be configured to allow incoming connections on port 80 or whatever port the HTTP server is listening on. In Windows, that might just mean making an exception for the Apache executable. Also, the HTTP server, PHP, and MySQL should be configured properly for a production environment (as opposed to a development or testing environment). You might want to think about who should have access and adjust the configuration accordingly (how-to).
aashish_2025 wrote:[...]problem when more than one user is using the same database[...]
Database management systems, MySQL included, are designed to handle such things gracefully (ACID). For single queries, it is the DBMS's responsibility. For inter-dependent queries, it is the programmer's responsibility to encapsulate the queries in a transaction.

(If any of that is false or didn't make sense, I'll blame it on sleep deprivation.)

Re: printing php reports & multiple comps. for one app.

Posted: Sat Aug 13, 2011 7:08 am
by aashish_2025
Thank you very much for your reply! But I didn't understand a few points. Hope you'll help there. :)
McInfo wrote:Printing is a process that requires some oversight. The paper tray could run empty. The ink/toner could run low. Paper could jam. The printer might be unplugged...
McInfo wrote:For single queries, it is the DBMS's responsibility. For inter-dependent queries, it is the programmer's responsibility to encapsulate the queries in a transaction.

Re: printing php reports & multiple comps. for one app.

Posted: Sun Aug 14, 2011 3:44 pm
by McInfo
McInfo wrote:Printing is a process that requires some oversight. The paper tray could run empty. The ink/toner could run low. Paper could jam. The printer might be unplugged...
Those are just some things to consider when designing your system. They are reasons you might not want unattended printing.
McInfo wrote:For single queries, it is the DBMS's responsibility. For inter-dependent queries, it is the programmer's responsibility to encapsulate the queries in a transaction.
I mean the database management system (DBMS) is ACID-compliant for individual queries. But if you select data with one query and update with another, the original data could have changed in the time between the two queries. Research "transactions" to learn more.