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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T17:44:04+00:00 2026-05-21T17:44:04+00:00

Here is my model. I’m not sure I’m on the right track, but this

  • 0

Here is my model. I’m not sure I’m on the right track, but this is a start. I have a survey form on my website and all of the values are numeric in INT fields. I want to compute the average of each of 10 columns. Rather than computing each result separately, I was wondering if there was a way to use a loop to process the results. So here it is:

function survey_averages() {

        $q = array(
                    '1' => 'q1',
                    '2' => 'q2',
                    '3' => 'q3',
                    '4' => 'q4',
                    '5' => 'q5',
                    '6' => 'q6',
                    '7' => 'q7',
                    '8' => 'q8',
                    '9' => 'q9',
                    '10' => 'q10'
                    );


        for ($i=1; $i<11; $i++) {
            $this->db->select_avg($q[$i]);
            $query[$i] = $this->db->get('survey');
        }

        return $query;

    }

If I’m on the right track, then how to I get back the results of the array? If I’m on the wrong track, what do I need to change? Also, if I do this in my controller:

foreach($query->result_array() as $row) {

How do I return the rows of my array? PHP is not letting me do $row->1 or $row->’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-21T17:44:05+00:00Added an answer on May 21, 2026 at 5:44 pm

    try var_dump($query->result_array())

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

Sidebar

Related Questions

i have this problem from mathematica,which refers to ising model.Here is a piece of
I have a criteria query not really working. Here the model: @Entity public class
I'm using CodeIgniter 2.1.2 and here's my situation right now. I have a model
I've got an interesting box-model problem here. I have a header full of links,
Here's my Model: class Persona extends AppModel { // This is just some arbitrary
Imagine you have this model: class Category(models.Model): node_id = models.IntegerField(primary_key = True) type_id =
I have a model with various properties but the one of interest is a
Right now I have a Rails 3 model for storing profile data. One of
class Content(models.Model): .....stuff here class Score(models.Model): content = models.OneToOneField(Content, primary_key=True) real_score = models.IntegerField(default=0) This
I have a webform-based macroeconomics model here that takes parameters and inputs and solves

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.