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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T12:47:17+00:00 2026-06-10T12:47:17+00:00

I do have a question : I cannot pass the data from model to

  • 0

I do have a question : I cannot pass the data from model to controller
You can see some of my codes, please help me.
It does not work!

this is my model “mymodel.php”

 ....

$query = $this->db->query("SELECT * FROM `rand` WHERE `used` = 0 LIMIT 0, 1");
    if($query){
    foreach ($query->result() as $row);
    }
    $t = "EXAMPLE/{$row->code}";
    function wandad() {
        return $t;
    }
.....

and this is my controller mycont.php

 ...
 $this->load->model('mymodel');

$data['new'] = $this->Mymodel->wandad();
$this->load->view('myview',$data);
 ...

and this is my view myview.php

 ....
 echo $new; 
 .....
  • 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-10T12:47:18+00:00Added an answer on June 10, 2026 at 12:47 pm

    Clearly you The model is not written properly and to corrent this simple do this

    1.) I put a default value on $t

    2.) I put the query >> loop on the inside function

    wandad

    so it can be executed once called from controller

    function wandad() {
        $query = $this->db->query("SELECT * FROM `rand` WHERE `used` = 0 LIMIT 0, 1");
        $t = "";
        if($query){
    
           foreach ($query->result() as $row){
              $t = "EXAMPLE/{$row->code}".'<br>';
           }
         }
    
        return $t;
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am learning C++ and have got a question that I cannot find the
I have a relatively simple question that I cannot seem to find the answer
I have a simple question. Of course it has many answers but I cannot
1) My question is that, when i have two large table which cannot be
I have a couple of questions. 1) Why cannot we see system tables (like
I have question. I have some app on facebook and getting this error Fatal
I have question about clean thory in Python. When: @decorator_func def func(bla, alba): pass
I have a class, say, CDownloader, that reads some XML data and provides access
I understand that if you have some function in a linq query that does
I have an application that does projection of data for my client over a

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.