Welcome Guest, Not a member yet? Register   Sign In
Help creating "next" button

Hi CI'ers... I have a small issue I would love some help with.

Right now I have a data entry form which when you hit submit takes you to a view page of that same information.

What I want to do is make a "next" button so when I edit the data entry form, I click next and go to the next record page. I have no idea how to do this because the db has lots of customers in it and i want to go to the next record for the customer i am on.

Any help is greatly appreciated.

[eluser]Nick Husher[/eluser]
If your database has ascending customer ID numbers, and you know the customer ID of the record you're looking at, you could run a query that selects the first customer with a higher ID than the one currently being viewed.

Thanks Nick - the problem with what you suggested is that the next id might not be for that customer

customer 1 has id 10,15, 17
customer 2 has id 11,12,13,14,16

I want to go from 10 to 15 for customer 1 when the form is submitted

[eluser]Michael Wales[/eluser]
Just query the database, ordered by id DESC, where the id is greater than the current record's ID.

$this->db->order_by('id', 'DESC');
$query = $this->db->get_where('records', array('customer_id' => $customer_id, 'id >' => $current_record), 1, 0);
if ($query->num_rows()) > 0) {
  return $query->row();
return FALSE;

thank you - will try that!

Theme © iAndrew 2016 - Forum software by © MyBB