title: Delete from the database using CodeIgniter
body: <p>I want to make one delete function, but I do not know what steps did wrong?</p>
  
  <p>This is the file model:</p>
  
  <pre><code>function delete()
  {
      $this-&gt;db-&gt;delete('ns_categories', array('cat_id' =&gt; $cat_id));     
  }
  </code></pre>
  
  <p>Controller:</p>
  
  <pre><code>function delete()
  {
      $this-&gt;cat_model-&gt;delete();
      $cat_id=$this-&gt;uri-&gt;segment(3);
      if($cat_id-&gt;delete()) return json_encode(array("success" =&gt; true));            
  }
  </code></pre>
  
  <p>View:</p>
  
  <pre><code>&lt;td class="centeralign"&gt;&lt;a class="deleterow" href="&lt;?php echo anchor('admin/categories/delete' .&lt;?php echo $row['cat_id']; ?&gt;"&gt;&lt;span class="icon-trash"&gt;&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;
  </code></pre>
  
  <p>Please help me.</p>