maideen Posted May 30, 2013 Share Posted May 30, 2013 Hi I have a problem to send php page with data to printer directly. Below code is working fine but only print issue. Pls help me Html page <style type="text/css"></style> <?php include '../templete/header.php'; ?> <Script Language="javascript"> function change_action() { var frm_obj=document.getElementById("frm"); frm_obj.action="data.php"; } </Script> <table class="tbl_table" align="center"> <form action="" method="POST" id="frm" > <tr> <td class="td_title" colspan="2"><strong>Outstanding Balance Report</strong></td> </tr> <tr> <td class="td_class_right">Until:</td> <td><input class="textdesign" type="text" id="datepicker1" name="datefrom" /></td> </tr> <tr> <td class="td_button" colspan="2"> <input class="buttondesign" type="submit" value="Search" name="search" onclick="change_action()"> <input class="buttondesign" type="submit" value="print" name="print" onclick="change_action()"> </td> </tr> </form> </table> data.php <?php include_once '../inc/connection.inc.php'; ?> <?php if (isset($_POST['search']) && $_POST['search'] != "" ) { $datefrom=$_POST["datefrom"]; $s = $dbh->prepare("EXECUTE usp_OutStanding_Balance ?"); $s->bindParam(1, $datefrom, PDO::PARAM_STR); $stmt = $s->execute(); $stmt = $dbh->query("SELECT * FROM vw_OutStanding_Balance ORDER BY MVName"); $stmt->setFetchMode(PDO::FETCH_ASSOC); include 'view.html.php'; } ?> <?php if (isset($_POST['print']) && $_POST['print'] != "" ) { $datefrom=$_POST["datefrom"]; $s = $dbh->prepare("EXECUTE usp_OutStanding_Balance ?"); $s->bindParam(1, $datefrom, PDO::PARAM_STR); $stmt = $s->execute(); $stmt = $dbh->query("SELECT * FROM vw_OutStanding_Balance ORDER BY MVName"); $stmt->setFetchMode(PDO::FETCH_ASSOC); include 'print.html.php'; } ?> print.html.php <?php include '../templete/print_head.php'; ?> <?php $groupby = ''; $displaySubTotal = FALSE; $subTotal = 0; $grandTotal = 0; $sub_debit=0; // maideen $grn_debit=0; // maideen $sub_credit=0; // maideen $grn_credit=0; // maideen $sub_bal=0; // maideen $grn_bal=0; // maideen ?> <div class="title">Outstanding Report</div> <table width="100%" align="center" cellpadding="4" cellspacing="1" class=tbl_table"> <tr><td colspan="6"><hr /></td></tr> <tr> <td class="tdempty"></td> <td class="tbl_header">MV CODE</td> <td class="tbl_header">MV NAME</td> <td class="tbl_header_right">DEBIT</td> <td class="tbl_header_right">CREDIT</td> <td class="tbl_header_right">BALANCE</td> <td class="tdempty"></td> </tr> <tr><td colspan="6"><hr /></td></tr> <?php if(isset($stmt)) { while($row = $stmt->fetch()): if($groupby!=$row['MVName']): if($displaySubTotal): ?> <?php $grn_debit += $sub_debit; $sub_debit=0; $grn_credit += $sub_credit; $sub_credit=0; $grn_bal += $sub_bal; $sub_bal=0; else: $displaySubTotal = TRUE; endif; $groupby = $row['MVName']; endif; ?> <tr> <td class="tdempty"></td> <td class="tbl_content"><?php echo $row['MVcode'];?></td> <td class="tbl_content"><?php echo $row['MVName'];?></td> <td class="tbl_content_right"><?php echo number_format($row['Debit'],2) ;?></td> <td class="tbl_content_right"><?php echo number_format($row['Credit'],2) ;?></td> <td class="tbl_content_right"><?php echo number_format($row['Balance'],2) ;?></td> <td class="tdempty"></td> </td> <?php $sub_debit += $row['Debit']; $sub_credit += $row['Credit']; $sub_bal += $row['Balance']; endwhile; $grn_debit += $sub_debit; $grn_credit += $sub_credit; $grn_bal += $sub_bal; ?> <tr><td colspan="6"><hr /></td></tr> <tr> <td colspan="2"> <td class="tbl_subtotal_left"><b>Grand Total</b></td> <td class="tbl_subtotal_right"><b><?php echo number_format($grn_debit,2); ?></b></td> <td class="tbl_subtotal_right"><b><?php echo number_format($grn_credit,2); ?></b></td> <td class="tbl_subtotal_right"><b><?php echo number_format($grn_bal,2); ?></b></td> </tr> <tr><td colspan="6"><hr /></td></tr> <?php }?> </table> <?php unset($dbh); unset($stmt); ?> Pls help me if anybody knows. I need once click the print button, system should send data to printer Regards Maideen Quote Link to comment Share on other sites More sharing options...
Muddy_Funster Posted May 30, 2013 Share Posted May 30, 2013 You're actualy looking for javascript help here, not PHP, unless you want to print it out to a printer that is attached and installed on the actual webserver... Quote Link to comment Share on other sites More sharing options...
maideen Posted May 30, 2013 Author Share Posted May 30, 2013 hi Muddy Can i have the javascript example? Maideen Quote Link to comment Share on other sites More sharing options...
dannon Posted May 30, 2013 Share Posted May 30, 2013 http://lmgtfy.com/?q=javascript+print+website Is this what you are looking for? 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.