Use data to Populate DB Tables and Another Form in PHP

I have a form that uses PHP to populate tables in a database. I want to use the same data to populate a printable form at the same time the tables are populated. I want this to be one step for users. When they click the "submit" button, I want the data sent to the database and to the printable form.

I am in the process of creating the printable form in the same php file I sent the data to the database. Is this the best way or is there a better way? If there is a better way, please give me some tips. Thanks in advance.
waynerayAsked:
Who is Participating?
 
Dave BaldwinConnect With a Mentor Fixer of ProblemsCommented:
That's pretty much the only way because that's when you have the data available to you.  I suppose you could retrieve it back from the database but that would take a little longer and it would still be the data you already have.  

I am about to do one that way but that's partly because I need to be able to display it later also.  So I'm going to create the printable form, send a copy to my customer and save a copy in the database.  That allows my customer to display it to their customer if and when they need to.
0
 
waynerayAuthor Commented:
Which is easier, populate the printable form first then send data to the database or does it matter?
0
 
Dave BaldwinFixer of ProblemsCommented:
It doesn't matter except that if you are calculating or generating some data, you have to do that before you can use it.  I would normally assign POST data to variables and do any filtering needed, do all the calculations that were needed, create the email or document, email it, and then put it in the database for later use. The last two, email and database are usually interchangeable because you have already made all the changes to the data by then.
0
 
waynerayAuthor Commented:
Thanks for your help. I asked a stupid question this morning. Not awake I guess. All is working fine. I have to submit to the database first to get info needed to populate other tables.
0
 
Dave BaldwinFixer of ProblemsCommented:
You're welcome, glad to help and thanks for the points.
0
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.

All Courses

From novice to tech pro — start learning today.