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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T18:48:40+00:00 2026-06-12T18:48:40+00:00

I was following the instruction to get the entire record from table, and load

  • 0

I was following the instruction to get the entire record from table, and load them into html table. this is the model

private $namatabel;

public function __construct() {
    parent::__construct();
    $namatabel='ms_kategori_material';
}

function read()
{        
   $sql = $this->db->get($this->namatabel);  

   if($sql->num_rows() > 0)
    {     
        foreach($sql->result() as $row)
        {  
            $data[] = $row;  
        }     
        return $data;  
    } 
    else 
    {  
        return null;  
    }  

}

then use the read() function on controller

public function __construct() {
    parent::__construct();
    $this->load->model('m_kategorimaterial');
}

function index()
{
    $data['c_row'] = $this->m_kategorimaterial->read();
//pass the c_row into the views  
    $this->load->view('v/vkategorimaterial', $data);  
}

to display them on the views

<?php  
$no = 1;   
foreach ($c_row as $row) { ?>  
    <tr id="row">  
        <td id="no"><?php echo $no;?></td>  
        <td id="judul"><?php echo $row->Kode_Kategori_Material_Jasa;?></td>  
        <td id="kategori"><?php echo $row->Nama_Material_Jasa;?></td>                 
    </tr>  
<?php  
    $no++;  
}  
?>  

but then I got an error saying, undefined variable c_row and invalid argument supplied foreach(). I thought I have sent the c_row variable through the c_kategorimaterial/index and copy pasting foreach statement. what went 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-12T18:48:41+00:00Added an answer on June 12, 2026 at 6:48 pm

    1)Check whether you are getting the data right by using print_r($data). If that went wrong,you are probably missing something in the query.

    2)If you got the db data perfectly,then just change the name of returning array in your model.

    function read()
    {        
       $sql = $this->db->get('ms_kategori_material');  
    
       if($sql->num_rows() > 0)
        {     
            foreach($sql->result() as $row)
            {  
                $c_row[] = $row;  
            }     
            return $c_row;  //comment this return part while debugging
            // print_r($c_row);
            //exit;
        } 
        else 
        {  
            return null;  
        }  
    

    }

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

Sidebar

Related Questions

Following the instruction found here: Insert a datasheet into a form I get an
I tried following the instruction s but can't get the plugin to work, the
I installed wxWidgets-2.8.10 following instructions from this page: http://wiki.wxwidgets.org/Compiling_and_getting_started Libraries directory: alex@alex-linux:/usr/local/lib$ ls |
I have a php query the returns the following JSON format from a table.
Following this instruction , I could run headless Eclipse plugin in side Eclipse IDE.
I am trying to use core-plot and I followed the instruction from the following
I'm following the instruction from an answer , why is my object that is
When compiling the following instruction: movl 4(%ebp), 8(%ebp) I got: too many memory reference
What does 0x0 indicate in the following instruction - lea 0x0(%esi,%eiz,1),%esi.
By following these instruction about autocompletion. I create an Index named suggestions. But when

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.