2014-12-31 28 views
-3

我不知道如何顯示我的數據庫交易數據爲自動金額,如會計系統。我該如何顯示我的信號交易數據作爲項目名稱

我需要在應收的金額,收到的款項,以及因顯示數據,像這樣的例子:http://i.stack.imgur.com/JSFW8.jpg

<?php $sqlnew="SELECT tranjection.id, tranjection.date, project.project_name,project.amount,tranjection.receive_ammount FROM project JOIN tranjection on project.project_name=tranjection.project_name where project.project_name='dp' " ; $resultnew=mysql_query($sqlnew); 
      $sl="1" ; ?> 


      <table width="400" border="0" cellspacing="1" cellpadding="0"> 
      <tr> 
       <td> 
       <table width="400" border="1" cellspacing="0" cellpadding="3"> 


        <tr> 
        <td align="center"><strong>Sl</strong> 
        </td> 
        <td align="center"><strong>Tran id</strong> 
        </td> 
        <td align="center"><strong>Tran date</strong> 
        </td> 
        <td align="center"><strong>Project Name</strong> 
        </td> 
        <td align="center"><strong>Receivable Amount</strong> 
        </td> 
        <td align="center"><strong>Receive Amount</strong> 
        </td> 
        <td align="center"><strong>Due</strong> 
        </td> 

        </tr> 







        <?php while($rows=mysql_fetch_array($resultnew)){ ?> 

        <tr> 
        <td> 
         <?php echo $sl++; ?> 
        </td> 
        <td> 
         <?php echo $rows[ 'id']; ?> 
        </td> 
        <td> 
         <?php echo $rows[ 'date']; ?> 
        </td> 
        <td> 
         <?php echo $rows[ 'project_name']; ?> 
        </td> 
        <td> 
         <?php echo $rows[ 'amount']; ; ?> 
        </td> 
        <td> 
         <?php echo $rec1=$receive_ammount=$rows[ 'receive_ammount']; ?> 
        </td> 
        <td> 
         <?php echo $rec1 ; ?> 
        </td> 
        </tr> 

        <?php } ?> 



       </table> 
       </td> 
      </tr> 
      </table> 
+0

以何種方式不實際的輸出你想要什麼不同?我不太明白你卡在哪裏。 – halfer

+0

這裏是數據庫圖像>> http://www.mediafire.com/view/1jqo1cc3obx8k0j/h3.jpg –

+0

@SakilSuva我已經給出了答案,你應該告訴我有關狀態。工作/不工作/你會稍後嘗試/測試/找到其他解決方案等:) –

回答

0

你應該表明你想說什麼作爲輸出/或者某種錯誤。

按我的理解,最後的PHP代碼應該像下面:

<?php while($rows=mysql_fetch_array($resultnew)){ 
     if(!isset($rec1)) $rec1=$rows["amount"]; 
     //as we only want to set this in first loop. don't create $rec1 before while, if you created any then use another variable here. $rec1 should be unset. ?> 
     <tr> 
      <td><?php echo $sl++; ?></td> 
      <td><?php echo $rows[ 'id']; ?></td> 
      <td><?php echo $rows[ 'date']; ?></td> 
      <td><?php echo $rows[ 'project_name']; ?></td> 
      <td><?php echo $rec1; ?></td> 
      <td><?php 
        echo $receive_ammount=$rows[ 'receive_ammount']; 
        $rec1-=$receive_amount; ?> 
      </td> 
      <td><?php echo $rec1 ; ?></td> 
     </tr> 
<?php } ?> 
相關問題