0

I have successfully written a dynamic form with output of the form and data posted to mysql. What I'd like to do now is save the output of my php to a variable which I can then pass to html2pdf for pdf generation. I've tried to outline my current file along with what I'd like below.

What I have:

if submitted do this {
   post data stored to variables
   dynamic form output including:
       field validation
       form data displayed in multiple tables
       multiple foreach loops of dynamic data with html tables and php variables within table cells.
   }
else do this {
   display form and collect user input
    submit buttons
   }

What I'd like

if submitted do this {
   post data stored to variables

   $var1 = dynamic form output including:
       field validation
       form data displayed in multiple tables
       foreach loop of dynamic data

   echo $var1;
   }
else do this {
   display form and collect user input
    submit buttons
   }

It doesn't look like ob_start(); and ob_get_clean(); gets me to where I need nor do php's heredoc strings. Any thoughts or examples would be much appreciated.

user1459766
  • 118
  • 2
  • 3
  • 16
  • 1
    if you have appropriate permissions in executing environment there is [wkhtmltopdf](http://code.google.com/p/wkhtmltopdf/) library which is more powerful than html2pdf (at least from my experience). Not quite clear what you're trying to accomplish and why `ob_start();` and `ob_get_contents();` does not work for you. – toske Jun 29 '12 at 21:02
  • Have a look here - it's how to redirect STDOUT from the screen into a file. http://stackoverflow.com/questions/937627/how-to-redirect-stdout-to-a-file-in-php – andrewsi Jun 29 '12 at 21:04
  • andrewsi. . . this looks very intriguing (for more than my current purpose!). So the way my php page would work I'd want to change the STDOUT for part of my code in order to write my table to a file and then change the STDOUT back to the screen in order to "echo" the file and display its contents to the screen. The link doesn't make mention of this. . . any suggestions? – user1459766 Jun 29 '12 at 21:37

0 Answers0