Welcome Guest, Not a member yet? Register   Sign In
Next button giving error when on last page.
#4

[eluser]Aken[/eluser]
Wasn't good enough for me. Here's even better:

Code:
// MODEL

public function get_image_by_id($id)
{
$query = $this->db->where('id', $id)->get('img');

if ($query->num_rows() === 1)
{
  return $query->row();
}

return FALSE;
}

public function get_next_image($current_id)
{
if (($nextimg = $this->get_image_by_id($current_id + 1)) === FALSE)
{
  $nextimg = $this->get_image_by_id(1);
}

return $nextimg;
}

// CONTROLLER

$data['next'] = $this->gallery_model->get_next_image($data['img']->id);


Messages In This Thread
Next button giving error when on last page. - by El Forum - 07-05-2012, 10:00 AM
Next button giving error when on last page. - by El Forum - 07-05-2012, 11:51 AM
Next button giving error when on last page. - by El Forum - 07-05-2012, 12:13 PM
Next button giving error when on last page. - by El Forum - 07-05-2012, 12:23 PM
Next button giving error when on last page. - by El Forum - 07-05-2012, 12:36 PM
Next button giving error when on last page. - by El Forum - 07-05-2012, 02:31 PM



Theme © iAndrew 2016 - Forum software by © MyBB