Welcome Guest, Not a member yet? Register   Sign In
Controller Issue [Duplicating data to a new entry]

Hi guys,

I may just be being really stupid here but any help would be greatly appreciated.

I have a method to recreate a 'ticket' with a new ticket number and all of the same information that comes with it. Along with each ticket are accompanying notes which come from a separate database table. I need to re-enter those notes with the new ticket number i've provided.

public function recreate_ticket()
  $this->data['notes'] = $this->note->order_by('created', 'desc')->get_many_by('ticket_id', $this->uri->segment(4));
   'no'  =>  $this->input->post('ticket_no'),
   'subject' =>  $this->input->post('subject'),
   'issue'  =>  $this->input->post('issue'),
   'user_id' =>  $this->input->post('user_id')
   foreach($notes as $n) {
    $note = array(
     'ticket_id'  =>  $this->uri->segment(4),
     'user_id'  =>  $n->user_id,
     'note'   =>  $n->note,
     'created'  =>  $n->created

The error i'm receiving is that my foreach statement is using an undefined variable which i'm guessing is because i'm trying to use the data in the same method i'm pulling it. Is there any way around this?

Thanks in advance.

You are foreach()ing over $notes. I don't see a defined $notes in that function. I see a $this->data['notes'], though Smile

Another thing is you have a redirect within a loop. That will trigger only once and exit the loop since it's redirecting back to tickets.

I love you a lot right now.

Works fantastically, thanks a million!


[Author Removed Post]

Theme © iAndrew 2016 - Forum software by © MyBB