[eluser]MaxEisley[/eluser]
Hello,
when i am selecting all cars, its ok, but when i need to get just one car, there is a problem.
This is my datamodel:
Code:
function getcar ($id) {
$q = $this->db->query('SELECT *
FROM car
WHERE car_ID = '.$id);
if ($q->num_rows() > 0) {
foreach ($q->result() as $row) {
$data[] = $row;
}
return $data;
}
}
This is constructor:
Code:
$data['car'] = $this->data_model->getcar($this->uri->segment(3));
When i echo $this->uri->segment(3) i get 1 or any other number.
And this view:
Code:
<?php echo $car->car_ID; ?>
And it writes this error:
Message: Trying to get property of non-object
Maybe i am badly getting one record.
Thanks for help.