WEB Need PHP Invoicing Solution...

Discussion in 'OT Technology' started by MSupply, Jun 20, 2008.

  1. MSupply

    MSupply New Member

    Joined:
    Aug 16, 2004
    Messages:
    488
    Likes Received:
    0
    I need to be able to output the order information i get from my site into some type of HTML invoice and have it sent to me/customer in email. Has anyone had experience with this before? I found several mock-up invoices that i like, i just have no clue how to integrate the php into them. Any help would be great...
     
  2. crazybenf

    crazybenf Active Member

    Joined:
    Nov 14, 2001
    Messages:
    15,575
    Likes Received:
    2
    just design the invoice in html+css and then wrap it in php with dynamic field updates...
     
  3. Slid.

    Slid. I'm a guy.

    Joined:
    Oct 25, 2001
    Messages:
    1,928
    Likes Received:
    0
    Location:
    NH
    If you have a customer, order and orderDetail table you'd have something like:

    Code:
    
    <?
    
      // grab order# 125
      $result = mysql_query("SELECT * FROM `customers` c JOIN `orders` o ON c.customerId=o.customerId JOIN `orderDetail` od on o.orderId=od.orderId WHERE o.orderId='125';");
    
      if(mysql_num_rows($result)<=0) {
    
        print "Order not found.";
        exit;
    
      } else {
    
        $row = mysql_fetch_assoc($result);
    
        // this is where you'd have your mock-up invoice template ...
        ?>
        
        <b>Customer Name:</b> <?=$row['firstName']?> <?=$row['lastName']?>
    
        <?
        
        // you'd need to loop through the results for each detail line if
        // there was more than one row returned (multi-line order)
        
      }
    
    ?>
    
    
    That's a start, pretty much what crazybenf said. You just want to take your template and fill in the 'slots' with database results. I know you said you'd like to email it, you can do that but you'll want to figure out how to print it to the screen first.
     
  4. crazybenf

    crazybenf Active Member

    Joined:
    Nov 14, 2001
    Messages:
    15,575
    Likes Received:
    2
    email and screen display are the same if you use HTML formatted mail. just mime it up up and make it happen.
     

Share This Page