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

  • Home
  • SEARCH
  • 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 533251
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T09:29:23+00:00 2026-05-13T09:29:23+00:00

I am currently working on a site that is being built on codeigniter, I

  • 0

I am currently working on a site that is being built on codeigniter, I am currently querying the data at the moment I think there could be possible 3 arrays that could be returned as array each with a varying amount of results, my question I cannot for life of me loop through the array I have at the moment,

my model looks like this

public function get_special_backgrounds() {
    $this->db->select('*');
    $this->db->from('background');
    $this->db->where('is_special', 1);

    $query = $this->db->get();
    return $query->result_array();
}

my controller

enter public function index() {
//  $this->output->enable_profiler(TRUE);
    $data = array();
    if($query = $this->category_model->get_all_online()) {
        $data['main_menu'] = $query;
    }
    $this->load->model('image_model');
    /*
    * Sort out the users backgrounds, basically do a check to see if there is a 'special' background
    * if there is not a 'special' background then IF the user is logged in and has a background of there
    * own show that one, if not show a generic one, if they are not logged in show a generic one
    */
    $image = array();
    if ($query = $this->image_model->get_special_backgrounds()) {
        $image = $query;
    }

    $data = array_merge($data, $image);
    die(print_r($data));
    $this->load->view('home/main_page.php', $data);
}

the array the gets return looks like this,

Array
(
    [main_menu] => CI_DB_mysql_result Object
        (
            [conn_id] => Resource id #28
            [result_id] => Resource id #35
            [result_array] => Array
                (
                )

            [result_object] => Array
                (
                )

            [current_row] => 0
            [num_rows] => 1
            [row_data] => 
        )

    [special] => Array
        (
            [0] => Array
                (
                    [background_id] => 6
                    [background_name] => Master-Backgrounds.png
                    [background_path] => /Users/Simon/Sites/mysite/media/uploads/backgrounds/
                    [is_special] => 1
                    [background_date_uploaded] => 1262687809
                    [users_user_id] => 1
                    [users_user_group_group_id] => 1
                )

            [1] => Array
                (
                    [background_id] => 11
                    [background_name] => Master-mysite-Template.png
                    [background_path] => /Users/Simon/Sites/mysite/media/uploads/backgrounds/
                    [is_special] => 1
                    [background_date_uploaded] => 1262795313
                    [users_user_id] => 5
                    [users_user_group_group_id] => 2
                )

        )

)
1
  • 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-13T09:29:24+00:00Added an answer on May 13, 2026 at 9:29 am

    Do you need to loop on the special part of the array?

    foreach ( $data['special'] as $row ) {
        // do stuff with the $row array
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

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.