Jump to content

How to print data from table in php


Aamirbuneri

Recommended Posts

I have school fees management system it's work perfect but now I need to add email print on receipt

I have email table but I don't know to print too on receipt kindly give me any idea to print (

<?php 

include 'db_connect.php';

$fees = $conn->query("SELECT ef.*,s.name as sname,s.id_no,concat(c.course,' - ',c.level) as `class` FROM student_ef_list ef inner join student s on s.id = ef.student_id inner join courses c on c.id = ef.course_id where ef.id = {$_GET['ef_id']}");

foreach($fees->fetch_array() as $k => $v){

 $$k= $v;

}

$payments = $conn->query("SELECT * FROM payments where ef_id = $id ");

$pay_arr = array();

while($row=$payments->fetch_array()){

 $pay_arr[$row['id']] = $row;

}

?>



<style>

 .flex{

  display: inline-flex;

  width: 100%;

 }

 .w-50{

  width: 50%;

 }

 .text-center{

  text-align:center;

 }

 .text-right{

  text-align:right;

 }

 table.wborder{

  width: 100%;

  border-collapse: collapse;

 }

 table.wborder>tbody>tr, table.wborder>tbody>tr>td{

  border:1px solid;

 }

 p{

  margin:unset;

 }



</style>

<div class="container-fluid">

 <p class="text-center"><b><?php echo $_GET['pid'] == 0 ? "Payments" : 'Payment Receipt' ?></b></p>

 <hr>

 <div class="flex">

  <div class="w-50">

   <p>EF. No: <b><?php echo $ef_no ?></b></p>

   <p>Student: <b><?php echo ucwords($sname) ?></b></p>

   <p>Course/Level: <b><?php echo $class ?></b></p>

  </div>

  <?php if($_GET['pid'] > 0): ?>

  <div class="w-50">

   <p>Payment Date: <b><?php echo isset($pay_arr[$_GET['pid']]) ? date("M d,Y",strtotime($pay_arr[$_GET['pid']]['date_created'])): '' ?></b></p>

   <p>Paid Amount: <b><?php echo isset($pay_arr[$_GET['pid']]) ? number_format($pay_arr[$_GET['pid']]['amount'],2): '' ?></b></p>

   <p>Remarks: <b><?php echo isset($pay_arr[$_GET['pid']]) ? $pay_arr[$_GET['pid']]['remarks']: '' ?></b></p>

  </div>

  <?php endif; ?>

 </div>

 <hr>

 <p><b>Payment Summary</b></p>

 <table class="wborder">

  <tr>

   <td width="50%">

    <p><b>Fee Details</b></p>

    <hr>

    <table width="100%">

     <tr>

      <td width="50%">Fee Type</td>

      <td width="50%" class='text-right'>Amount</td>

     </tr>

     <?php 

    $cfees = $conn->query("SELECT * FROM fees where course_id = $course_id");

    $ftotal = 0;

    while ($row = $cfees->fetch_assoc()) {

     $ftotal += $row['amount'];

    ?>

    <tr>

     <td><b><?php echo $row['description'] ?></b></td>

     <td class='text-right'><b><?php echo number_format($row['amount']) ?></b></td>

    </tr>

    <?php

    }

    ?>

    <tr>

     <th>Total</th>

     <th class='text-right'><b><?php echo number_format($ftotal) ?></b></th>

    </tr>

    </table>

   </td>   

   <td width="50%">

   <p><b>Payment Details</b></p>

    <table width="100%" class="wborder">

     <tr>

      <td width="50%">Date</td>

      <td width="50%" class='text-right'>Amount</td>

     </tr>

     <?php 

      $ptotal = 0;

      foreach ($pay_arr as $row) {

       if($row["id"] <= $_GET['pid'] || $_GET['pid'] == 0){

       $ptotal += $row['amount'];

     ?>

     <tr>

      <td><b><?php echo date("Y-m-d",strtotime($row['date_created'])) ?></b></td>

      <td class='text-right'><b><?php echo number_format($row['amount']) ?></b></td>

     </tr>

     <?php

      }

      }

     ?>

     <tr>

      <th>Total</th>

      <th class='text-right'><b><?php echo number_format($ptotal) ?></b></th>

     </tr>

    </table>

    <table width="100%">

     <tr>

      <td>Total Payable Fee</td>

      <td class='text-right'><b><?php echo number_format($ftotal) ?></b></td>

     </tr>

     <tr>

      <td>Total Paid</td>

      <td class='text-right'><b><?php echo number_format($ptotal) ?></b></td>

     </tr>

     <tr>

      <td>Balance</td>

      <td class='text-right'><b><?php echo number_format($ftotal-$ptotal) ?></b></td>

     </tr>

    </table>

   </td>   

  </tr>

 </table>

</div> )

 

My WhatsApp number is 

+923409871374

Pls help me

Edited by requinix
please use the Code <> button when posting code
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.