[eluser]Erocanti[/eluser]
Hey! New to CodeIgniter,
I need some help find my mistake here, my view is not displaying the variables that I hope i'm passing correctly. Below is my code.
Thanks in advance for any assistance and advice.
Controller
Code:
function edit()
{
$id = $this->uri->segment(3, 0);
$data = array();
if ($id !== 0)
{
$this->load->model('dashboard_m');
$data['fields'] = $this->dashboard_m->getRecord($id);
$data['fields'] = $data['fields']['0']; //This seems to solve the situation for mean time, I've used this type of query before and this is the first time this has responded this way.
$this->load->view('edit', $data);
}
else
{
$this->index();
}
}
Updated
Model
Code:
function getRecord($id)
{
$this->db
->from('calls')
->where('logid', $id);
$query = $this->db->get();
return $query->result_array();
}
View
Code:
<div class="clearfix">
<label>Incident Number</label>
<input type="text" name="incnumber" id="incnumber" value="<?php echo $fields['0']['incnumber']; ?>" />
</div>
Error
Code:
A PHP Error was encountered
Severity: Notice
Message: Undefined index: incnumber
Filename: views/edit.php
Line Number: 99
print_r($fields)
Code:
Array ( [0] => stdClass Object ( [logid] => 43 [type_of_incident] => Slip/Fall [dispatcher] => test
[txdate] => 2011-06-30 [supervisornotified] => 910 [post] => 123 [txtime] => 21:18
[related_calls] => None [status] => Active [incidentclass] => Other [priority] => Normal
[description] => Lorem... [comments] => Lorem... [incnumber] => 110603B43 [station] => Alpha
[location] => Escalator [pdnotified] => checked [frnotified] => checked [pdcase] => 000000
[fralarm] => 000000 [sector] => 3 [locationinfo] => Lorem... ) )