Avatar of fastfind1

asked on 

Print Form Letters Based on PHP and MySQL database

I have a data entry web application that saves info into a mysql database table using php.  One of the fields in one of the tables is a case number.  Another field in the same table is a problem number.  There are only 10 problem numbers that can be assigned to a case number.  

I need to automate the following process, using PHP.

Each problem number has a form letter.  Right now the form letters are in Word, but I don't need to generate a Word file or PDF file, what I need is a printout.

So each time a new record is entered (hence a new case number is entered), I need the web app to enter the case number into the correct form letter (based on the problem number), and then take the merged form letter to a new web browser so that the user can print the letter.

So if case number 2 with problem number 8 was entered into the mysql database.  The next step for the web app (using PHP) would be to get the form letter for problem number 8, insert the case number 2 into the correct spot on the form, then display the merged form letter in a new browser window so that the employee can click print and print out the letter.  

One more requirement:  the web app that stores the data in a database allows the employee to enter 10 new records with one click of the submit button.  This is already working well.  So after clicking the submit button and adding 10 new records to the mysql database, I need a script that pulls the correct form letter (based on the problem number), for each of the 10 newly entered records, merges the case number into the correct form letter, and then prints to paper all of the form letters at once.  I don't need to save the merged form letters, only print them once.

What I was thinking is that when the employee adds the 10 new records, I can have a hidden field that stores a value of N in the mysql database table in a field called printed.  Then on the next page of the web app, PHP script can pull a list of case numbers and corresponding problem numbers from the database in a dynamic table based on all of the records in the table with a value of N in the printed column.  

I have been able to do this.

But now I need to take those values from the dynamic table, select and print the appropriate merged forms, and then update the mysql database table to show a value of Y in the printed column, so that I know those records have already been printed.

Any suggestions?
PHPWeb ApplicationsMySQL Server

Avatar of undefined
Last Comment
Steve Bink

8/22/2022 - Mon