Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9177991
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T17:26:58+00:00 2026-06-17T17:26:58+00:00

I have the following Model, Controller and view. Using PHP Point of Sale 11.3.

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T17:26:59+00:00Added an answer on June 17, 2026 at 5:26 pm

    It should have been like this

    Model

    function getmax()
    {
        $query = $this->db->query("SELECT max(item_id) as MaxID FROM phppos_items");
        return $query->row();
    }
    

    Controller

    function view()
    {   
        $data['row']=$this->Item->getmax();      
        $this->load->view("items/form",$data);
    }   
    

    View

    $options['name']    =   'item_number';
    $options['id']      =   'item_number';
    $options['value']   =   set_value('item_number',$row->MaxID);
    
    echo form_input($options);  
    

    You see i am using row

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following model, view and controller. Model public class Person { public
I have the following Model and Controller files, and when i visit this url,
I have a controller/model hypothetically named Pets. Pets has the following declarations: belongs_to :owner
I have the following code in my zf2 controller: <?php namespace Accounting\Controller; use Zend\Mvc\Controller\ActionController,
I have the following view: @using SuburbanCustPortal.SuburbanService <br /> <br /> <table> @if (ViewData[CustomerData]
I have the following View code: @using (Html.BeginForm(Login, Press, FormMethod.Post)) { <fieldset> <legend>User Registration</legend>
I have the following view that i need to display an error message when
I have the following in my Razor view: @using (Html.BeginForm(Edit, MyController, FormMethod.Post)) { <div
So I have the following code: @model Project.Models.ViewModels.SomeViewModel @using (Html.BeginForm(SomeAction, SomeController, new { id
I have the following model in my view that I am passing to it:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.