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 9224633
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:22:18+00:00 2026-06-18T04:22:18+00:00

My form field looks like this echo form_label(‘Quantity’, ‘quantity’); echo form_input(‘quantity’, $quantityx); I modified

  • 0

My form field looks like this

    echo form_label('Quantity', 'quantity');
    echo form_input('quantity', $quantityx);

I modified it to retain form values

    echo form_label('Quantity', 'quantity');
    echo form_input('quantity', $this->input->post('quantity'));

I set the $quantityx above in the code behind in order to populate a value from the database so a user can edit a row.

How can I retain the value for validations, and have a variable to populate from the database at the same time?

I have tried this a well

    echo form_label('Quantity', 'quantity');
    echo form_input('quantity', set_value($quantityx));

Thanks for any suggestions

  • 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-18T04:22:20+00:00Added an answer on June 18, 2026 at 4:22 am

    You can set them like this, if set_value('columnanme') returns false then a form $_POST did not take place so what it will do is get the data from the data base example
    $profile->firstname

    $firstname = set_value('firstname') == false ? $profile->firstname : set_value('firstname');
    $lastname = set_value('lastname') == false ? $profile->lastname : set_value('lastname');
    

    Use it like:

    echo form_label('Firstname', 'fname');
    echo form_input('firstname', $firstname);
    echo form_label('Firstname', 'lnamey');
    echo form_input('firstname', $lastname);
    

    in your case you can do:

    $quantity = set_value('Quantity') == false ? $quantityx : set_value('Quantity');
    

    ANd on your form:

    echo form_label('Quantity', 'quantity');
        echo form_input('quantity', $quantity);
    

    Assuming that $quantityx holds the data from your databse

    EDIT
    =============================================

    Just use set_values() second parameter as the default value. i.e set_value('name_of_input_field',$data_from_databse_as_default);
    If this does not work, then use my first answer.

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

Sidebar

Related Questions

I have a form with a hidden field that looks something like this: <form
I've got a bit of Django form code that looks like this: class GalleryAdminForm(forms.ModelForm):
I have form, where some fields are looks like rows, so I can add/delete
In this question: If a form field has multi validators, how to let play
I'd like to generate a select form field, where a user can select one
I have a form I've built in PHP and storing the form field values
How do I pass a few of my form field(s) values to a controller
I have a dynamic table row created via PHP that looks like this: while($carrier
I have a simple PHP Array called $categories that looks like this: Array (
I wondered if this was possible: It looks like this: <tr> <td> Full Name:

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.