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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T09:21:28+00:00 2026-06-12T09:21:28+00:00

I’m fairly new to CI. I have a customer database which stores a bunch

  • 0

I’m fairly new to CI. I have a customer database which stores a bunch of customer information. I have also created an Update controller to update current customer information. The update form is the same form as the new customer form but for the value I’ve got it pulling the old data from the database. My problem is it pulls all the data and displays it in it’s propor field except the drop down field. Any ideas how to fix this?

CONTROLLER:

function edit_customer($id){
    $data['success']=0;
    if($_POST){
        $data_customer=array(
            'first_name'=>$_POST['first_name'],
            'last_name'=>$_POST['last_name'],
            'phone'=>$_POST['phone'],
            'email'=>$_POST['email'],
            'website'=>$_POST['website'],
            'business_name'=>$_POST['business_name'],
            'business_add'=>$_POST['business_add'],
            'business_cityState'=>$_POST['business_cityState'],
            'cc_type'=>$_POST['cc_type'],
            'cc_number'=>$_POST['cc_number'],
            'cc_exp'=>$_POST['cc_exp'],
            'cc_cvd'=>$_POST['cc_cvd'],
            'billing_add'=>$_POST['billing_add'],
            'billing_zip'=>$_POST['billing_zip'],
            'package'=>$_POST['package'],
            'assigned_zip_code'=>$_POST['assigned_zip_code'],
            'active'=>1
        );
        $data_customer['active'] = 1;
        $this->customer->update_customer($id,$data_customer);
        $data['success']=1;
    }
    $data['customer']=$this->customer->get_customer($id);

    $this->load->view('header');
    $this->load->view('edit_customer',$data);
    $this->load->view('footer');

}

MODEL:

function update_customer($id, $data_customer){
    $this->db->where('id', $id);
    $this->db->update('customers', $data_customer);
}

VIEW DROPDOWN:

<label for="cc_type">Credit Card Type:</label>
                <select name="cc_type" value="<?=$customer['cc_type'] ?>">
                  <option></option>
                  <option>Visa</option>
                  <option>Mastercard</option>
                  <option>American Express</option>
                  <option>Discover</option>
                </select>
  • 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-12T09:21:29+00:00Added an answer on June 12, 2026 at 9:21 am

    For an option to be selected, you need to add the selected attribute to the <option> elements.

    For example:

    <select name="type">
      <option>a</option>
      <option>b</option>
      <option selected="selected">c</option>
      <option>d</option>
    </select>​
    

    View it here: http://jsfiddle.net/3M4xv/

    So in your code, you could do something like this:

    <select name="cc_type">
      <option <?php echo ($customer['cc_type']=='Visa')?'selected="selected"':''; ?>>Visa</option>
      <option <?php echo ($customer['cc_type']=='Mastercard')?'selected="selected"':''; ?>>Mastercard</option>
      <option <?php echo ($customer['cc_type']=='American Express')?'selected="selected"':''; ?>>American Express</option>
      <option <?php echo ($customer['cc_type']=='Discover')?'selected="selected"':''; ?>>Discover</option>
    </select>
    

    Hope it helps 🙂

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

Sidebar

Related Questions

I have a view passing on information from a database: def serve_article(request, id): served_article
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have an autohotkey script which looks up a word in a bilingual dictionary
I have an array which has BIG numbers and small numbers in it. I
I have a text area in my form which accepts all possible characters from
I have a reasonable size flat file database of text documents mostly saved in
I have a bunch of posts stored in text files formatted in yaml/textile (from
I am trying to loop through a bunch of documents I have to put
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i

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.