列方式记录显示

时间:2015-02-01 11:55:07

标签: php mysql sql pivot

我试图以列方式显示我的sql数据。目前的输出是

Customer Name       Amount          Date
XYZ                 1200            2015.01.01
XYZ                 600            2015.01.02

但我希望显示如下:

           2015.01.01       2015.01.2
XYZ        1200             600

我的代码如下:

<!-- language: lang-html -->

    <table border="0" id="info">

    <?php
        $conn = mysql_connect('localhost','root','test');
        if(!$conn) die("Failed to connect to database!");
        $status = mysql_select_db('tulient', $conn);
        if(!$status) die("Failed to select database!");

        $sql = mysql_query("select * from add_deposite where CUSTOMER_NAME like '%$term%' and DATE between '$term1' and '$term2'");


        $rs = mysql_query("select * from add_deposite where CUSTOMER_NAME like '%$term%' and DATE between '$term1' and '$term2' ");
        $CUSTOMER_NAME = "";
            while($row = mysql_fetch_array($rs))
                {

                    echo '<tr>';
                    echo '<td><div align="left">'.$row['CUSTOMER_NAME'].'</div></td>';
                    echo '<td><div align="left">'.$row['AMOUNT'].'</div></td>';

                    echo '<td><div align="left">'.$row['DATE'].'</td>';
                    echo '</tr>';
                }

            ?> 
           </table>

完成任务需要您宝贵的建议。 提前谢谢。

里彭

0 个答案:

没有答案