I have the following Model, Controller and view. Using PHP Point of Sale 11.3. I'm trying to take the max value in a DB column and display it in a text field in view.
Model:
function getmax()
{
$query = $this->db->query("SELECT max(item_id) FROM phppos_items");
return $query->row();
}
Controller:
function view()
{
$data['max_id']=$this->Item->getmax();
$this->load->view("items/form",$data);
}
View:
<?php
echo $max_id; //line 16. Error Here.
echo form_input(array(
'name'=>'item_number',
'id'=>'item_number',
'value'=>set_value('item_number',$max_id)) //is this right??
);
?>
Am getting two errors when execution.
A PHP Error was encountered
Severity: 4096
Message: Object of class stdClass could not be converted to string
Filename: items/form.php
Line Number: 16
A PHP Error was encountered
Severity: Warning
Message: htmlspecialchars() expects parameter 1 to be string, object given
Filename: helpers/form_helper.php
Line Number: 625
I'm getting the max_id without any issues when used as dropdown in view.
<?php echo form_dropdown('max_id',$max_id);?>
But I need this value to be filled in default in the form text field. Thanks in advance.