Basically all I want to do is from my view page which is displaying a specific article then having a delete link to a page with a field and a button for deleting that article with the id displayed in that field. 

I have had a go at this for the last couple of days trying to put the id in the URL link i.e "delete?id=20" and trying to access it with a $\_GET and then I tried "delete/20" and URI segments. 
Then I attempted at using sessions etc but i am not sure which is best as I haven't got any of them working.

I have decided to show my untouched code and start from scratch here is my code:

**view.php**

```
<?php 
echo '<h2>'.$news_item['title'].'</h2>';
echo '<p>'.$news_item['text'].'</p>'; 
?><br><br>

<a href="http://website.com/CodeIgniter/index.php/news">
Go to latest news</a>

<a href = "http://website.com/CodeIgniter/index.php/news/delete">Delete</a><br>

```

**delete.php**

```
<h2>Delete a news item</h2>

<?php echo validation_errors(); ?>
<?php echo form_open('news/delete') ?>

<form>
<label for="delete">Article Number</label><br> 
<input name="id" class="resizedTitlebox" value="id" /><br>      
<br>

<input type="submit" name="submit" value="Delete news item" /></form>

```

**news.php (controller)**

```
 <?php

 class News extends CI_Controller {

public function __construct()
{
    parent::__construct();
    $this->load->model('news_model');
}

public function view($slug)

    {

$data['news_item'] = $this->news_model->get_news($slug);

   if (empty($data['news_item']))
   {
    show_404();
   }

$data['title'] = $data['news_item']['title'];

$this->load->view('templates/header', $data);
$this->load->view('news/view', $data);
$this->load->view('templates/footer');

    }

    public function delete() {
    {   
      $this->load->helper('form');
      $this->load->library('form_validation');

      $data['title'] = 'Delete news item';

      $this->form_validation->set_rules('id',  'required');

      if ($this->form_validation->run() === FALSE)
      {
                $this->load->view('templates/header', $data);   
                $this->load->view('news/delete');
                $this->load->view('templates/footer');

      }
      else
      {
            $data['id'] = $this->news_model->delete('id');
            $this->load->view('news/success');
              }
             }
         }

```

**news\_model.php (model)**

```
    <?php

    class News_model extends CI_Model {

public function __construct()   {

    $this->load->database();
}

   public function get_news($slug = FALSE){

     $this->load->helper('text');

 if ($slug === FALSE){
     $this->db->order_by('id', 'desc');
    $query = $this->db->get('news');
     return $query->result_array();
 }

 $query = $this->db->get_where('news', array('slug' => $slug));
 return $query->row_array();
     } 

     public function set_news(){

     $this->load->helper('url');

     $slug = url_title($this->input->post('title'), 'dash', TRUE);

     $data = array(
         'id' => $this->input->post('id'),
          'title' => $this->input->post('title'),
          'slug' => $slug,
          'text' => $this->input->post('text'));

      return $this->db->insert('news', $data);
        }

    public function delete ($id)  {

          $this->db->where('id',$this->input->post('id'));
          $this->db->delete('news');
      }
     }

```

**routes.php (config)**

```
    $route['news/(:any)'] = 'news/view/$1';
    $route['news/delete'] = 'news/delete';
    $route['news'] = 'news';
    $route['default_controller'] = 'news';
    $route['404_override'] = '';

```

Thanks in advance for any help given!
-------------------------------------

@jeroen answer

"You are not passing any value in the delete link; you should add an ID either to the path or the query string" - I assume you mean like 

```
  <a href = "http://website.com/CodeIgniter/index.php/news/delete?article_id=<?php echo $news_item['id']; ?>">Delete</a>

```

So using article\_id. Then I can define article\_id in the delete controller? I am not sure how this can be done.

answer:
 $this->input->get(article\_id)