使用 PHP+MySQL 创建发票
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10057480/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Creating an Invoice using PHP+MySQL
提问by azzaxp
I want to create a invoice as described in this post here.
我想按照此处的帖子中的说明创建发票。
I am able to do the edits here and get even the print. But I need some suggestion to store the same into Database. I am Good with MySQL, just a beginner in PHP, So can any one suggest me how to have multiple inserts. and storing the customer info in customer table, and order info in order table, and the relation between customer and Order in another. with reference to the above example.
我可以在这里进行编辑甚至打印。但是我需要一些建议将其存储到数据库中。我对 MySQL 很好,只是 PHP 的初学者,所以任何人都可以建议我如何进行多个插入。并将客户信息存储在客户表中,订单信息存储在订单表中,客户和订单之间的关系存储在另一个中。参考上面的例子。
Demohere.
演示在这里。
回答by Baba
They are 4 sections in the INVOICE system , Client Information , Invoice Information , Invoice Items and Items Total
他们是发票系统中的4个部分,客户信息,发票信息,发票项目和项目总计
Invoice Information
Invoice Information
$mysqli = new mysqli ( $dbHost, $dbUser, $dbPass, $dbName ); // Replace with
// relevant
// information
$result = $mysqli->query ( "SELECT * FROM invoiceInfo" );
$invoice = $result->fetch_assoc ();
<div id="page-wrap">
<textarea id="header">INVOICE</textarea>
<div id="identity">
<textarea id="address">
<?php echo $invoice['address']?>
</textarea>
<div id="logo">
<div id="logoctr">
<a href="javascript:;" id="change-logo" title="Change logo">Change
Logo</a> <a href="javascript:;" id="save-logo" title="Save changes">Save</a>
| <a href="javascript:;" id="delete-logo" title="Delete logo">Delete
Logo</a> <a href="javascript:;" id="cancel-logo"
title="Cancel changes">Cancel</a>
</div>
<div id="logohelp">
<input id="imageloc" type="text" size="50" value="" /><br /> (max
width: 540px, max height: 100px)
</div>
<img id="image" src="images/aviation/logo2.png" alt="logo" />
</div>
</div>
Customer Information
Customer Information
$result = $mysqli->query ( "SELECT * FROM clientTable WHERE clientID = '{$invoice['clientID']}' " );
$clientInfo = $result->fetch_assoc ();
$totalPayment = 0;
<div id="customer">
<textarea id="customer-title"><?php echo $clientInfo['clientName']?>
Address: <?php echo $clientInfo['clientAddress'] ?> </textarea>
<table id="meta">
<tr>
<td class="meta-head">Invoice #</td>
<td><textarea>000123</textarea></td>
</tr>
<tr>
<td class="meta-head">Date</td>
<td><textarea id="date"><?php echo date("Y-m-d g:i:s",time())?></textarea></td>
</tr>
<tr style="display: none">
<td class="meta-head">Total Payment</td>
<!-- <td><div class="due">-N-<?php echo $totalPayment ?></div></td> -->
<td><div>-N-<?php echo $totalPayment ?></div></td>
</tr>
</table>
</div>
Invoice Items
Invoice Items
<?php
$result = $mysqli->query ( "SELECT * FROM itemTable WHERE clientID = '{$invoice['clientID']}' " );
while ( $item = $result->fetch_assoc () ) {
?>
<tr class="item-row">
<td class="item-name"><div class="delete-wpr">
<textarea><?php echo $item['name'] ?></textarea>
<a class="delete" href="javascript:;" title="Remove row">X</a>
</div></td>
<td class="description"><textarea>
<?php echo $item['description']?>
</textarea></td>
<td><textarea class="cost">-N-<?php echo $item['unit'] ?></textarea></td>
<td><textarea class="qty"><?php echo $item['quantity'] ?></textarea></td>
<td><span class="price">-N-<?php echo $item['prize'] ?></span></td>
</tr>
<?php
}
?>
Item Totalthis would be done automatically
Item Total这将自动完成
I hope this helps
我希望这有帮助
Thanks :)
谢谢 :)

