Click here to Skip to main content
15,888,610 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I want to print one select row form data MySQL by use PHP it's my code.

else if($_SESSION['branch_name']=='Madenah St.')
          {
              $view_user="SELECT * FROM madenah_st";
              $run=mysqli_query($dbcon,$view_user);
              while ($row=mysqli_fetch_array($run))
              {
                  $no_invo=$row[0];
                  $dta_invo=$row[1];
                  $amm_invo=$row[2];
                  $b_amm_invo=$row[3];
                  $d_b_amm_invo=$row[4];
                  $cus_nam=$row[5];
                  $cus_pho_num=$row[6];
                  $brc_typ=$row[7];?>
  <tr>
      <td><?php echo $no_invo;?></td>
      <td><?php echo $dta_invo;?></td>
      <td><?php echo $amm_invo;?></td>
      <td><?php echo $b_amm_invo;?></td>
      <td><?php echo $d_b_amm_invo;?></td>
      <td><?php echo $cus_nam;?></td>
      <td><?php echo $cus_pho_num;?></td>
      <td><?php echo $brc_typ;?>
      <button onclick="myfun()">print page</button>
      <script type="text/javascript">
      function myfun(){
        window.print();
      }</script>

    </td>


What I have tried:

print one select row form data MySQL by using PHP I mean print to printer
Posted
Updated 19-Feb-20 17:20pm

1 solution

php is not designed for that particular purpose. one possible solution can be you care a printable version of HTML let the user print by their own. Window print() Method[^]

You can also improve printing quality by using PDF. i.e create the PDF in PHP and send it to client side and again let the client print. Many tools are out there for this purpose, FPDF, MPDF, TCPDF etc. FPDF, MPDF are derived from TCPDF
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900