[eluser]DannGrant[/eluser]
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.
Code:
public function recreate_ticket()
{
$this->data['notes'] = $this->note->order_by('created', 'desc')->get_many_by('ticket_id', $this->uri->segment(4));
if($this->ticket->insert(array(
'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
);
$this->note->insert($note);
redirect('admin/tickets');
}
}
}
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.