douyingyu5573 2012-04-07 19:09
浏览 106
已采纳

使用PHP + MySQL创建发票

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.

Demo here.

  • 写回答

1条回答 默认 最新

  • dongzhuo2010 2012-04-07 21:51
    关注

    They are 4 sections in the INVOICE system , Client Information , Invoice Information , Invoice Items and Items Total

    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

    $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

    <?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 Total this would be done automatically

    I hope this helps

    Thanks :)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 结构功能耦合指标计算
  • ¥20 visual studio中c语言用ODBC链接SQL SERVER
  • ¥50 AI大模型精调(百度千帆、飞浆)
  • ¥15 非科班怎么跑代码?如何导数据和调参
  • ¥15 福州市的全人群死因监测点死亡原因报表
  • ¥15 Altair EDEM中生成一个颗粒,并且各个方向没有初始速度
  • ¥15 系统2008r2 装机配置推荐一下
  • ¥15 悬赏Python-playwright部署在centos7上
  • ¥15 psoc creator软件有没有人能远程安装啊
  • ¥15 快速扫描算法求解Eikonal方程咨询