2015-06-22 20 views
0

我必須顯示包含鏈接的閃存數據。我嘗試了以下,但鏈接沒有顯示,因爲它應該。如何在codeigniter中發送閃存數據,其中一部分是鏈接

如何在flashdata中添加鏈接? 我嘗試這樣做:

$cancell = "<a href='<?php echo site_url('document/index');?>Cancell</a>"; 
      $this->session->set_flashdata('success', 
       'You successfully created the document! ' . $cancell .', if you want to cancell it!'); 
    redirect('document/index/'); 
+0

'重定向( '文件/索引/');'當你使用這個它會重新加載頁面。所以你的閃存數據alws保持丟失。使用'$ this-> load-> view();' –

+0

顯示Flash數據。我的問題是,當你點擊Cancell鏈接時,鏈接以這種方式顯示:http:// localhost:9080/projectname/index.php/Document/<?php echo site_url( –

回答

1

嘗試像下面這段代碼的一些事情,但要確保網址助手自動加載

URL Helper Codeigniter

控制器

$link = anchor('document/index', 'cancel'); 

$message = 'You successfully created the document!' .' '. $link .' '. 'if you want to cancell it!'; 

$this->session->set_flashdata('success', $message); 

redirect('document/index'); 

查看

<p><?php echo $this->session->flashdata('success');?></p>

+0

Thank you!It works :) –

+0

Your welcome :) – user4419336

相關問題