2011-04-27 59 views
1

我試圖讓下面的函數鏈接被點擊時運行,然後加載以前的頁面,但我似乎與任何PHP錯誤一個空白頁結束:功能使用說明 - >組織

查看:

<?php if(is_array($get_images)): ?> 
      <?php foreach($get_images as $image): ?> 
      <img src ="<?=base_url()?>includes/uploads/gallery/thumbs/<?=$image['thumbname']?>" alt="<?= $image['description']?>"> <a href="deleteimage/delete/<?=$image['id']?>">Delete</a> 
      <?php endforeach; ?> 
    <?php endif; ?> 

控制器:

function delete($id) { 

     $id = $this->uri->segment(3); 
     $this->image_model->deleteImage($id); 
     $page['get_images'] = $this->image_model->getImages(); 
     $data['cms_pages'] = $this->navigation_model->getCMSPages(); 
     $data['title'] = 'Delete Gallery Image'; 
     $data['content'] = $this->load->view('admin/deleteimage',$page,TRUE); 


    } 

} 

回答

2

首先,破壞性的東西,如DELE一個圖像應該是POST,而不是GET。

至於代碼,這樣的事情應該工作(假定最後的閉括號意味着你的函數是一個類的方法)...

// However you extract params in your framework. 
$id = $request->getParam('id'); 

// Instantiate the class. 
$controller = new ImageController; 

// Call the method. 
$controller->delete($id);