Quando você recebe postagens, o nome da coluna é
book_id . Quando você exclui é id . Talvez você precise alterá-lo para book_id . Também
$this->uri->segment(3) neste caso retornará null, porque function delete() não tinha parâmetros. Mais detalhes leia aqui
Mas vou fazer algumas alterações:
Controlador:
public function delete()
{
$id=$this->uri->segment(3); // Try to write any id here, or in function put parameter
$this->book_model->deletepost($id);
$data['books']=$this->book_model->getposts();
$this->load->view('showbooks',$data);
}
Modelo:
public function getposts() {
return $this->db->get('books')->result_array();
}
public function deletepost($id) {
$this->db->where('book_id',$id); // I change id with book_id
$this->db->delete('books');
}