Home arrow PHP arrow Page 5 - Invoice Management in a PHP Invoicing System

Creating Unpaid.php - PHP

If you're running a business in which you're invoicing clients, you need some way to keep track of which invoices have gone out and which clients have paid. In this second article of a four-part series that covers the creation of a PHP invoicing system, we create the parts that deal with this kind of invoice management.

  1. Invoice Management in a PHP Invoicing System
  2. Finishing the Invoice Page
  3. Generating a Table
  4. Code for Creating an Invoice
  5. Creating Unpaid.php
  6. Creating a new invoice
By: Leidago
Rating: starstarstarstarstar / 31
September 13, 2006

print this article



This page shows all the unpaid invoices. This is what it looks like:

There is really nothing to it. All that it does is list all the unpaid invoices as well as what action you want to take. We follow the same method to display the needed headers and info. So create a new PHP document and save it as unpaid.php. Then at the very top of the page add the following code:

Code5 Unpaid.php
include "config.php";
$query_invoice = "SELECT *,DATE_FORMAT(inv_date,'%D %M %Y') as
idate FROM invoices INNER JOIN client ON cid=id WHERE status =
$result_invoice = mysql_query($query_invoice);
$num_invoice = mysql_num_rows($result_invoice);

As before, we run a query to retrieve all the invoices marked as unpaid in the database. We also include an inner join to include matching records from the client table:

$query_invoice = "SELECT *,DATE_FORMAT(inv_date,'%D %M %Y') as
idate FROM invoices INNER JOIN client ON cid=id WHERE status =

We then store the number of rows returned in the $num_invoice variable. Next we create the table with the headers:

<tr valign="top">
          <td width="13%"><strong>Invoice # </strong></td>
          <td width="24%"><strong>Client Name

          <td width="20%"><strong>Date Issued

          <td width="18%"><strong>Total(incl VAT)</strong></td>
          <td width="25%"><strong> Action </strong></td>

Then we create the dynamic section of the table based on the returned rows:

                        if($num_invoice > 0){
                        while($invoice = mysql_fetch_assoc
        <tr valign="top">
                          <?  $query_invdetails = "SELECT totwVAT
FROM clientinv WHERE finv='".$invoice['invno']."'";
if(!$result_invdetails= mysql_query($query_invdetails)){
echo mysql_error();
$num_invdetails = mysql_num_rows($result_invdetails);
          <td><? if(!isset($_GET['act'])){?><a
Reminder</a><? }else{?>Reminder sent!<? }?> </td>

Finally if there are no results returned in the query, we print a message stating so:

<? }
                        <td colspan="5"><p>No unpaid
                        <? }?>

And thatís it for this page. Next we are going to look at how to create a new invoice.

>>> More PHP Articles          >>> More By Leidago

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...

Developer Shed Affiliates


Dev Shed Tutorial Topics: