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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T19:50:37+00:00 2026-06-13T19:50:37+00:00

I am new in codeIgniter and I having a bit of trouble with my

  • 0

I am new in codeIgniter and I having a bit of trouble with my database and dropdown menu.

Here is my function to get the information I need…

protected $tbl_name = 'club';

public function get($id = 0, $object = TRUE)
    {
        // select * from users where id = 0
        // check if id is provided
        if($id) {
            // id provided - retrieve a specific user
            $query = $this->db->get_where($this->tbl_name, array('id' => $id));
            // check if object type is requested
            if($object) {
                // object is requested
                $data = $query->row();
            }
            else {
                // array is requested
                $data = $query->row_array();
            }
        }
        else {
            // id not provided - retrieve all users
            $query = $this->db->get($this->tbl_name);
            // check if object type is requested
            if($object) {
                // object is requested
                $data = $query->result();
            }
            else {
                // array is requested
                $data = $query->result_array();
            }
        }
        return $data;
    }

Here is where I call it in my controller

$data['clubname'] = $this->club_model->get();

and this is in my view for the dropdown

<tr><td><?php echo form_label('Club Name: ', 'clubname'); ?></td><td><?php echo form_dropdown('clubname', $clubname['name']); ?></td><td><?php echo form_error('clubname'); ?></td></tr>

but I get these errors

A PHP Error was encountered

Severity: Notice

Message: Undefined index: name

Filename: individual/individual_club.php

Line Number: 7
A PHP Error was encountered

Severity: Warning

Message: Invalid argument supplied for foreach()

Filename: helpers/form_helper.php

Line Number: 331

What Am I doing wrong?

  • 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-13T19:50:39+00:00Added an answer on June 13, 2026 at 7:50 pm

    The problem lies in your form_dropdown('clubname', $clubname['name']) call. The second parameter is wrong. form_dropdown expects an array. See the documentaiton

    From your query’s results, you would need to build an array of clubs. Something along the lines of :

    // array is requested
    $data = array();
    foreach ($query->result_array() as $row)
    {
       $data[$row['club_id']] = $row['club_name'];
    }
    

    Replace club_id and club_name with your table’s column names for the name and id of the clubs. After that, change your form_dropdown to form_dropdown('clubname', $clubname).

    Like this, $clubname is an array of clubs.

    Hope this helps!

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

Sidebar

Related Questions

I'm really new to CodeIgniter and am having some trouble getting started. I see
I'm fairly new to Codeigniter as well as MVC and I'm having a bit
I'm having trouble getting the Codeigniter email library working on a new server. This
I am still new into Codeigniter framework. Today I read about Database Caching http://codeigniter.com/user_guide/database/caching.html
I'm still very new to codeigniter. The issue i'm having is that the file
I am having trouble simply making multiple pages with CodeIgniter. For example, I am
Good morning! I'm having great success so far with CodeIgniter. I'm new to PHP
Having a problem with image manipulation in codeigniter - it bombs when I get
I am new to codeigniter and I am having some issues loading a model
I am having a problem with inserting a new row in database using Doctrine

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.