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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T12:30:34+00:00 2026-05-20T12:30:34+00:00

I am relatively new to codeigniter and am struggling to understand how would save

  • 0

I am relatively new to codeigniter and am struggling to understand how would save and access data from multiple controllers so was wondeing if anyone here could help me understand this.

I need to create a function inside codeigniter which returns a data array for me to pass to a view and create a form dropdown.

Below is the code that will be used in the function

switch($type) {
case 'text':
$data = array (
                'equals'        => 'Equals',
                'notequal'      => 'Does Not Equal',
                'startswith'    => 'Starts With',
                'endswith'      => 'Ends With',
                'contains'      => 'Contains',
                'notcontain'    => 'Does Not Contain',
                );
break;

case 'numeric':

$data = array (
                        'equals'        => 'Equals',
                        'notequal'      => 'Does Not Equal',
                        'less'          => 'Less Than',
                        'greater'       => 'Greater Than',
                        'equalless'     => 'Less Than Or Equal To',
                        'equalgreater'  => 'Greater Than Or Equal To'
                        );

break;

case 'date':

$data = array (
                        'equals'        => 'Equals',
                        'notequal'      => 'Does Not Equal',
                        'before'        => 'Before',
                        'after'         => 'After',
                        'equalbefore'   => 'Before Or Equal To',
                        'equalafter'    => 'After Or Equal To'
                        );
break;
}

I will then be passing the data array that is returned from this function into a view using it to create a form dropdown using the following code:

echo form_dropdown('conditions', $data);

I am not sure whether I need to create a helper for this or something else?

Thanks for looking

  • 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-05-20T12:30:35+00:00Added an answer on May 20, 2026 at 12:30 pm

    Still not exactly sure what you’re trying to accomplish, but generally in the past for dropdown content that I need to use many times across a project, I’ll contain the values within a helper.

    like this…

    conditions_helper.php

    <? if ( ! defined('BASEPATH')) exit('No direct script access allowed');
    
    if ( ! function_exists('hotel_types_dropdown')) {
    
        function date_dropdown_values() {
    
            $data = array (
                'equals'        => 'Equals',
                'notequal'      => 'Does Not Equal',
                'before'        => 'Before',
                'after'         => 'After',
                'equalbefore'   => 'Before Or Equal To',
                'equalafter'    => 'After Or Equal To'
            );
    
            return $data;
        }
    

    and you would continue to format your different dropdown setups with corresponding function names.

    So once you add it to your autoload.php or load it within the controller you want to use it in. Just call it with date_dropdown_values() and it will return your array for use in a dropdown.

    Then in your controller…

    switch($type) {
        case 'text':
            $data->dropdown_values = text_dropdown_values();
            break;
    
        case 'numeric':
            $data->dropdown_values = numeric_dropdown_values();
            break;
    
        case 'date':
            $data->dropdown_values = date_dropdown_values();
            break;
    }
    
    $this->load->view('path/to/view', $data);
    

    And then in your view

    <?php echo form_dropdown('conditions', $dropdown_values); ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Being relatively new to the .net game, I was wondering, has anyone had any
I'm relatively new to CodeIgniter and am making my first CI project in which
relatively new programmer here. Look at the two classes defined below. I'd like to
I am relatively new to C++, coming from the happy-go-lucky world of Python. I
I'm relatively new to django.. In the app that I'm building, there are multiple
Relatively new to rails and trying to model a very simple family tree with
Being relatively new to functional programming, I expend lots of energy wondering is this
Caveat: I'm relatively new to coding as well as TextMate , so apologies if
I'm relatively new to J2ME and about to begin my first serious project. My
I am relatively new to web services and am wondering what the standard best

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.