PHP
  Home arrow PHP arrow Invoice Management in a PHP Invoicing ...
Dev Shed Forums 
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Sun Developer Network 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Moblin 
JMSL Numerical Library 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
PHP

Invoice Management in a PHP Invoicing System
By: Leidago
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 3 stars3 stars3 stars3 stars3 stars / 21
    2006-09-13

    Table of Contents:
  • Invoice Management in a PHP Invoicing System
  • Finishing the Invoice Page
  • Generating a Table
  • Code for Creating an Invoice
  • Creating Unpaid.php
  • Creating a new invoice

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Invoice Management in a PHP Invoicing System


    (Page 1 of 6 )

    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.
    Downloadable files for this article are available here and here.

    Continuing with the PHP Invoicing series, we will now concentrate on how to create, view and print an invoice. So let’s get started!

    Create a new PHP document and save it as main.php. Refer to fig2 to see what the main page looks like. There are essentially three pages that deal with invoices:

    • Allinv.php – Lists all invoices in the database.
    • Unpaid.php – Lists all unpaid invoices.
    • NewInvoice.php – Enables you to generate a new invoice.

    There are also related pages that handle deleting and updating invoices.

    Create a new document and save it as allinvoices.php. The page consists of both PHP and HTML code. Add the following code:

    Code4  Allinv.php
    <?
    include "config.php";
    $query_invoice = "SELECT *,DATE_FORMAT(inv_date,'%D %M %Y') as
    idate,DATE_ADD(inv_date,INTERVAL 30 DAY) as duedate  FROM
    invoices ORDER BY invno DESC";
    $result_invoice = mysql_query($query_invoice);
    $num_invoice = mysql_num_rows($result_invoice);
    ?>

    This is a standard query that retrieves all the invoices in the database. The only things worth explaining are the DATE_FORMAT() and DATE_ADD() functions. The DATE_FORMAT function does exactly what the name implies: it formats the date that is stored in the way that you want it. The DATE_ADD() function adds a specified number of days (in this case it is 30) to the date column in the database.

    I wanted the date formatted as dd mm yyyy which is displayed as, for example, "18th June 2005." There are a variety of ways in which you can format a date. Check http://www.mysql.com/ for more details.  The 30 days that I’ve specified in the DATE_ADD() function will help us determine whether an invoice is overdue.

    The number of rows returned by the query is stored in the "$num_invoices" variable. As you’ll see in a little while, it will be used to determine how many rows a table should have.

    More PHP Articles
    More By Leidago


       · As one can read in the comments on the first of this series, there is no data...
       · Minor Snark - 17.5% does equal x times 17.5 divided by 100, but it would be better...
       · Thanks for the observation. Will keep it in mind next time around!
     

       

    PHP ARTICLES

    - Validating Web Forms with the Code Igniter P...
    - Output Buffering
    - Paginating Database Records with the Code Ig...
    - HTTP Headers in Web Development
    - Project Management: Administration
    - Building a Database-Driven Application with ...
    - User Authentication for a Project Management...
    - Introduction to the CodeIgniter PHP Framework
    - Adding Users for a Project Management Applic...
    - Migrating Class Code for a MIME Email to PHP...
    - Login and Logout Authentication for a Projec...
    - Composing Messages in HTML for MIME Email wi...
    - Project Management: Authentication
    - A Better Way to Determine MIME Types for MIM...
    - Project Management Overview





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway