Jump to content

Print out


vj5

Recommended Posts

I am getting a report based on inputing broker name and date. I am retreiving the data from the mysql database and everything works fine. I have one problem. When I take a print out of the report, the input fields , submit button everything comes out in the printout. I want to take a print out of only the report. how do I do that?example of my code:

if isset(formaction)......{echo "<div>";echo "<form name= "" action="" method="post">";''''''''''''echo "<input type=submit name=formaction value="View Growth Report"> <input type=submit name=formaction value="cancel">";echo "</form>";echo "</div>";}if preg_match........{programming codes goes here......}

Link to comment
Share on other sites

I am getting a report based on inputing broker name and date. I am retreiving the data from the mysql database and everything works fine. I have one problem. When I take a print out of the report, the input fields , submit button everything comes out in the printout. I want to take a print out of only the report. how do I do that?
if isset(formaction)......{echo "<div>";echo "<form name= "" action="" method="post">";''''''echo "<input type=submit name=formaction value="View Growth Report"> <input type=submit name=formaction value="cancel">";echo "</form>";echo "</div>";}if preg_match........{programming codes goes here......}

So what I'm getting out of this is that you have your report printed out to the browser from the DB after using your form.....and you are wanting to print out that report but not the form elements? options: A ) create a pop-up for the report to be printed. B ) use an javascript onclick event to call a function that basically does form.visible = false; .... or hide the div with your form ...don't know if I addressed the right problem :) ... if not correct me in what you are trying to do.hope this helps
Link to comment
Share on other sites

So what I'm getting out of this is that you have your report printed out to the browser from the DB after using your form.....and you are wanting to print out that report but not the form elements? options: A ) create a pop-up for the report to be printed. B ) use an javascript onclick event to call a function that basically does form.visible = false; .... or hide the div with your form ...don't know if I addressed the right problem :) ... if not correct me in what you are trying to do.hope this helps
Correct. how to create a pop-up for the report to be printed? Can you give an example? Is there a way to do in the php code itself?
Link to comment
Share on other sites

java script: to open a Pop-up that runs a .php file (pulling your report out of the DB)on your submit button use the javascript onclick event like this ---- <input type='submit' onClick="java script:window.open('http://google.com');return false" name='formaction'>but instead of opening the window there just make it run a function like below:function popwindow(){<!-- ...get form element values (send these along in the url like : thePopUpPhp.php?name='+VariableNameHere+'&date='+VariableDateHere; ) <-- something like that i believe--> window.open(url,'name','height=200,width=150'); }make sure to send your variables through the url and just have the pop-up run a php script like you are doing to pull out the report information..related to the php option belowfor a PHP option- have the action="" in your form go to the .php file that prints out the report (this of course won't create a pop-up but i'm pretty sure those variables will be sent to that php file and you just have to grab them and run your script to make the report<?phpif( isset($_POST['name']) && isset($_POST['date']) ) {$name = $_POST['name'];$date = $_POST['date'];....run your script to pull and print out the report from the DB}sorry took a bit to reply multi-tasking at the moment....there are better examples and ways to go about it...this is just what came to me right away.luck

Link to comment
Share on other sites

oh yeah....if you are sending the variables through the url use $_GET instead of $_POST for the php file (you don't actually need a type='submit'....type='button' would work if you are sending them through with the javascript onclick event by way of url )anyway, taking the train home from work so i won't be able to reply for a good 45mini'll check when i get home just in casebut i hope that got it or at least gave you some ideas to start with

Link to comment
Share on other sites

The easiest way will be to use CSS.
@media print{  form, input  {	display: none;  }}

http://www.w3schools.com/css/css_mediatypes.asp

So, will it be like the one below:
@media printif isset(formaction)......{echo "<div>";echo "<form name= "" action="" method="post">";''''''''''''echo "<input type=submit name=formaction value="View Growth Report"> <input type=submit name=formaction value="cancel">";echo "</form>";echo "</div>";}display: none;  }if preg_match........{programming codes goes here......}

Please let me know if I understand right. Thankyou.

Link to comment
Share on other sites

No, CSS code will either go in a CSS sheet that you attach to the page using a <link> tag in the head section, or you can put CSS directly into the head inside a <style> tag. It doesn't have anything to do with PHP.

Link to comment
Share on other sites

No, CSS code will either go in a CSS sheet that you attach to the page using a <link> tag in the head section, or you can put CSS directly into the head inside a <style> tag. It doesn't have anything to do with PHP.
Could you let me how to do, I am still stuck with this?
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...