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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T02:38:30+00:00 2026-06-17T02:38:30+00:00

Soooo, I have this function public function playerslist() { $this->load->database(); $data = $this->db->get(‘skaters’)->result(); $this->load->helper(‘url’);

  • 0

Soooo, I have this function

public function playerslist()
{
    $this->load->database();
    $data = $this->db->get('skaters')->result();
    $this->load->helper('url');
    $this->load->view('playerslist', array('data' => $data));
}

and what I am trying to do use a foreach in my view to return data like so

<?php 
    foreach($data as $row => $value){
        echo $row;
    }
?>

and it just returns 0…I did a

<?php 
    print_r($data);
?> 

and it returned this….

Array ( [0] => stdClass Object ( 
    [id] => 1 
    [firstname] => Steve 
    [lastname] => Stamkos 
    [position] => F 
    [team] => TBL 
    [gp2013] => 0 
    [g2013] => 0 
    [a2013] => 0 
    [pm2013] => 0 
    [pim2013] => 0 
    [ppg2013] => 0 
    [ppa2013] => 0 
    [shg2013] => 0 
    [sha2013] => 0 
    [s2013] => 0 
    [s%2013] => 0 
    [fp2013] => 0 
    [gp2012] => 82 
    [g2012] => 60 
    [a2012] => 0 
    [pm2012] => 0 
    [pim2012] => 0 
    [ppg2012] => 0 
    [ppa2012] => 0 
    [shg2012] => 0 
    [sha2012] => 0 
    [s2012] => 0 
    [s%2012] => 0 
    [fp2012] => 0 
    [gp2011] => 0 
    [g2011] => 0 
    [a2011] => 0 
    [pm2011] => 0 
    [pim2011] => 0 
    [ppg2011] => 0 
    [ppa2011] => 0 
    [shg2011] => 0 
    [sha2011] => 0 
    [s2011] => 0 
    [s%2011] => 0 
    [fp2011] => 0 
    [gp2010] => 0 
    [g2010] => 0 
    [a2010] => 0 
    [pm2010] => 0 
    [pim2010] => 0 
    [ppg2010] => 0 
    [ppa2010] => 0 
    [shg2010] => 0 
    [sha2010] => 0 
    [s2010] => 0 
    [s%2010] => 0 
    [fp2010] => 0 
) )

What Am I doing wrong and do I use $data in a foreach?

  • 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-17T02:38:31+00:00Added an answer on June 17, 2026 at 2:38 am

    It should be something like

    foreach($data as $key=>$row)
    {
        echo $row->firstname;
    }
    

    Because $data is an array of rows. So in your version, $row is the index of the row in the array, while $value is the row itself.

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

Sidebar

Related Questions

soooo i have this function that prints one of 5 random texts ON an
suppose I have this string: some striinnngggg <a href=something/some_number>linkk</a> soooo <a href=someotherthing/not_number>asdfsadf</a> I want
BEFORE CHAOS I used to have this one... at the head part <script type=text/javascript>$(function()
soooo i can't seem to get some div alignments to work. basically, i have
Soooo we have this system here that's working as follows: We have a Java
I have tried so many things but I don't understand this sooo confusing. I
I'm a bit confused about displaying data from a MySQL database. I would like
A VERY nice to have would be if I could edit object-literals in this
I have been going in circles for a few hours with this and have
I have an application with a view-based NSTableView in it. Inside this table view,

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.