Solved

Use data to Populate DB Tables and Another Form in PHP

Posted on 2013-06-25
5
187 Views
Last Modified: 2013-06-26
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
Comment
Question by:wayneray
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 83

Accepted Solution

by:
Dave Baldwin earned 250 total points
ID: 39276859
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
 

Author Comment

by:wayneray
ID: 39277671
Which is easier, populate the printable form first then send data to the database or does it matter?
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 39278904
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
 

Author Closing Comment

by:wayneray
ID: 39278937
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
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 39278999
You're welcome, glad to help and thanks for the points.
0

Featured Post

Technology Partners: 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!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question