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

[eluser]alberto24[/eluser]
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.
#2

[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.
#3

[eluser]alberto24[/eluser]
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
#4

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

Code:
$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;
#5

[eluser]alberto24[/eluser]
thank you - will try that!




Theme © iAndrew 2016 - Forum software by © MyBB