emediastudios Posted November 12, 2007 Share Posted November 12, 2007 i have a file that loads all my records from a table in my database. What i want is to add the option of posting the info in a selected record to a file, either a pdf or text file so that it is printer friendy. At the moment the only option available is to delete the record, can i add another button to my form to do what i am aiming? Quote Link to comment Share on other sites More sharing options...
phpQuestioner Posted November 12, 2007 Share Posted November 12, 2007 not quit following you - why don't you use an alternate stylesheet for printer friendly version or alternate php page for a printer friendly layout? Quote Link to comment Share on other sites More sharing options...
emediastudios Posted November 12, 2007 Author Share Posted November 12, 2007 Thats probably not a bad idea. At the moment my client gets to browse his application form records through his admin section. Its all layed out and looks real stylish, i originally wanted to be able to give an option to post to pdf so he could print out his proccessed application forms for his records. He could then delete the record from his database. Is this a big process? If so i can have the info just post to a simple php file without the graphics and make it printer friendy that way. Can i just add a button beside the delete button (print) and have it post the form data to another file?  Quote Link to comment Share on other sites More sharing options...
phpQuestioner Posted November 12, 2007 Share Posted November 12, 2007 you could dynamically display a pdf file with PHP/MySQL by creating a PHP page and setting the header("Content-type: application/pdf") for the PHP header and query your database to insert the content you wish to display for the printer friendly version. Â Â check out the manual for more about PDFs in PHP: http://us2.php.net/pdf. Quote Link to comment Share on other sites More sharing options...
emediastudios Posted November 12, 2007 Author Share Posted November 12, 2007 Thanks, ill give it some research Quote Link to comment Share on other sites More sharing options...
emediastudios Posted November 12, 2007 Author Share Posted November 12, 2007 Can i add another button and give it another form action, so that my delete button does one form action and my print button does a differnt one, say action = printfriendly.php Quote Link to comment Share on other sites More sharing options...
phpQuestioner Posted November 12, 2007 Share Posted November 12, 2007 yeah - why not? Â you could create a separate form with a submit button or just create a button and assign a javascript dom event - like "onclick". Â Â example: Â <input type="button" value="Printer Friendly" onclick="document.location.href='printfriendly.php';"> Quote Link to comment Share on other sites More sharing options...
emediastudios Posted November 12, 2007 Author Share Posted November 12, 2007 Ok that looks good, opens the right page, but how i get the info to post over to pf.php I have these <?php echo $row_Recordset1['id']; ?> throughout my form. I thought by putting this <?php echo $_POST['id']; ?> in my pf.php file the data would post across Quote Link to comment Share on other sites More sharing options...
phpQuestioner Posted November 12, 2007 Share Posted November 12, 2007 I would just do it like this: Â <input type="button" value="Printer Friendly" onclick="document.location.href='printfriendly.php?id=<?php echo $row_Recordset1['id']; ?>';"> Â Then query your "printfriendly.php" page with PHP/MySQL and set the layout how ever you want it to print out. Quote Link to comment Share on other sites More sharing options...
emediastudios Posted November 12, 2007 Author Share Posted November 12, 2007 Ok i added your new code, sorry but im still a noobie, this code in my pf.php file doesnt show any details on id  <?php </head> <body> Application Form Number <?php echo $_POST['id']; ?> </body> </html> ?> Quote Link to comment Share on other sites More sharing options...
phpQuestioner Posted November 12, 2007 Share Posted November 12, 2007 where are you wanting the application form number to be pulled from your database, a form submission, or a query string? Quote Link to comment Share on other sites More sharing options...
emediastudios Posted November 12, 2007 Author Share Posted November 12, 2007 form submission, as i have a repeated region showing all records in a repeating form, i was going to create form varibles and post them, i have this on a diffent site that sends the data from a form to a full details file that echoes form varibles, want to do the same thing i guess. Quote Link to comment Share on other sites More sharing options...
phpQuestioner Posted November 12, 2007 Share Posted November 12, 2007 if your form is posting the variable - try this: Â $fid = $_POST['id']; Application Form Number <?php echo "$fid"; ?> Â Â if your sending the variable through a query string (ie: printerfriendly.php?id=1) Â try this: Â $fid = $_GET['id']; Application Form Number <?php echo "$fid"; ?> Quote Link to comment Share on other sites More sharing options...
emediastudios Posted November 12, 2007 Author Share Posted November 12, 2007 I got it Did this Application Form Number <?php echo $_GET['id']; ?> Thanks man, Quote Link to comment Share on other sites More sharing options...
phpQuestioner Posted November 12, 2007 Share Posted November 12, 2007 that works too, but it's good coding practices to declare your variable. Â like so: Â Â <?php $id = $_GET['id']; ?> Application Form Number <?php echo $_GET['id']; ?> Quote Link to comment Share on other sites More sharing options...
emediastudios Posted November 12, 2007 Author Share Posted November 12, 2007 I cant get the rest of the info to post, only the id? is this because it was added to the button? Can i get the rest of the info to post accross or can i draw it from the database using the id number to display the right record? thanks so much for your help Quote Link to comment Share on other sites More sharing options...
emediastudios Posted November 12, 2007 Author Share Posted November 12, 2007 I have this code now, using yours <?php $id = $_GET['id']; $name= $_GET['name']; ?> Application Form Number <?php echo $_GET['id']; ?> <br> Name <?php echo $_GET['name']; ?> Quote Link to comment Share on other sites More sharing options...
phpQuestioner Posted November 12, 2007 Share Posted November 12, 2007 I cant get the rest of the info to post, only the id? is this because it was added to the button? Can i get the rest of the info to post accross or can i draw it from the database using the id number to display the right record? thanks so much for your help   database is your best bet for getting the rest of your variables. Quote Link to comment Share on other sites More sharing options...
emediastudios Posted November 12, 2007 Author Share Posted November 12, 2007 Im sooooooo close i can smell it, Dont mean to ask to much but how would i query the data base to show record by filtering through posted id number. Thanks again 4 ur help Quote Link to comment Share on other sites More sharing options...
phpQuestioner Posted November 12, 2007 Share Posted November 12, 2007 <?php mysql_connect("localhost","username","password"); mysql_select_db("dBname"); $results = mysql_query("select * from tblName where id='$id'"); while($puller=mysql_fetch_array($results)) { // List Your Variables Like This And So On...... $variable1=$puller["fieldNameHere"]; // Then Echo Out The Above Variables Where Ever You Want Them echo "$variable1"; } ?> Quote Link to comment Share on other sites More sharing options...
emediastudios Posted November 12, 2007 Author Share Posted November 12, 2007 Thanks heaps for your help Pasted this code in my page and it shows a blank page  <?php mysql_connect("localhost","root","5050888202"); mysql_select_db("preparetowin"); $results = mysql_query("select * from application where id='$id'"); while($puller=mysql_fetch_array($results)) { // List Your Variables Like This And So On...... $variable1=$puller["id"]; // Then Echo Out The Above Variables Where Ever You Want Them echo "$variable1"; } ?> Quote Link to comment Share on other sites More sharing options...
emediastudios Posted November 12, 2007 Author Share Posted November 12, 2007 Fixed it up had to put an extra line of code it <?php $id = $_GET['id']; mysql_connect("localhost","root","5050888202"); mysql_select_db("preparetowin"); $results = mysql_query("select * from application where id='$id'"); while($puller=mysql_fetch_array($results)) { // List Your Variables Like This And So On...... $variable1=$puller["id"]; $variable2=$puller["name"]; // Then Echo Out The Above Variables Where Ever You Want Them echo "$variable1"; echo "$variable2"; } ?> Your the best. Thanks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.