• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 193
  • Last Modified:

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.
0
wayneray
Asked:
wayneray
  • 3
  • 2
1 Solution
 
Dave BaldwinFixer 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

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now