mohammed_22 0 Light Poster

i want to display all related images according to the image selected here is my code...
my control looks like this..

public function product_details($p_id)
  {

   $data['active_mn']='product_details';
   $data['detail']=$this->roxmodel->get_related_image($p_id,4,0);
   var_dump($data['detail']);
   $this->load->view('product_details',$data);

  }

my model looks like this

 public function get_related_image($p_id,$limit,$offset)
  {

      $this->db->order_by("gallery.id","desc");
      $this->db->where('category_id',$p_id);
      $query=$this->db->get('gallery',$limit,$offset);

      return $query->result();
    }

my view page looks like this

 <?php foreach($detail as $row){?>
<a href="#">
<img class="primary-image" ima="<?php echo base_url();?>images/<?php echo $row->image;?>" src="<?php echo base_url();?>images/<?php echo $row->image;?>" alt="" />
<img class="secondary-image" ima="<?php echo base_url();?>images/<?php echo $row->image;?>" src="<?php echo base_url();?>images/<?php echo $row->image;?>" alt="" />
</a>
<?php }?>

my table structure looks like this
id,image,category_id
while selecting image i should have to get all related images but here iam not getting