2012-05-23 60 views
0

我的網站有問題。我希望此視圖執行的是顯示與用戶標識相關的所有發票(在另一個表中),而不是代碼打印出一個視圖中的所有發票(不考慮用戶標識)。在查看cakephp調試吐出的sql語句時,它顯示了空白處(不用擔心,我將包含實際的sql語句)。我也創建了會話代碼,但我不確定如何對其進行編碼,以便mysql數據將說明userid =當前用戶的位置;cakephp mysql錯誤

這裏是視圖

<table width="100%" border="1"> 

      <table width="100%" border="1"> 
       <tr> 
        <th>Biller</th> 
        <th>Subject</th> 
        <th>Date</th> 
        <th>Action</th> 
       </tr> 
       <?php foreach($invoices as $invoice):?> 
        <tr> debug($invoices); 
         <td align='center'><?php echo $this->Html->link($invoice['Invoice']['biller'], 
         array('action' => 'viewinvoice', $invoice['Invoice']['id'])); ;?> </td> 
         <td align='center'><?php echo $invoice['Invoice']['subject']; ?></td> 
         <td align='center'><?php echo $invoice['Invoice']['datecreated']; ?></td> 
         <td align='center'><a href="viewinvoice"><button>View Invoice</button></a><a href="disputeinvoice"><button>Dispute Invoice</button></a></td> 
        </tr> 
       <?php endforeach; ?> 

      </table> 

這裏的代碼是在類與這種觀點

public function payinvoice($id = null){ 
     $this->set('title_for_layout', 'Pay Invoice'); 
     $this->set('stylesheet_used', 'homestyle'); 
     $this->set('image_used', 'eBOXLogoHome.jpg'); 
     $this->layout='home_layout'; 

     $this->set('invoices', $this->Invoice->find('all' , array('conditions' => array('Invoice.biller' => $id)))); 
} 

和這裏的代碼是SQL代碼的網站是使用檢索數據

SELECT `Invoice`.`id`, `Invoice`.`to`, `Invoice`.`biller`, `Invoice`.`subject`, `Invoice`.`description`, `Invoice`.`amount`, `Invoice`.`datecreated`, `Invoice`.`duedate` FROM `pra_cake`.`invoices` AS `Invoice` WHERE `Invoice`.`biller` IS NULL 

回答

1

它看起來像你沒有傳入一個id到你的頁面。 URL應該是這樣的:

/invoices/payinvoice/2 
+0

如何將一個能夠實現那? – user1393064

+0

查看Moyed Ansari的回答 – RichardAtHome

1

這可能是網址的問題

試試這個

<?php echo $this->Html->link('Invoice', 
    array('controller' => 'invoices', 
      'action' => 'payinvoice', 
      $invoice['Invoice']['id']) 
    );?> 

就會產生

<a href="/invoices/payinvoice/6">Invoice</a> 
+0

上面有一個網站上的鏈接,但它只有'發票/ payinvoice /' – user1393064

+0

你可以發佈你用來填充$發票的代碼和調試[$發票]的輸出嗎? – RichardAtHome