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

The Archive Base Latest Questions

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

lets say the query from my controller is $query. how to display the data

  • 0

lets say the query from my controller is $query.
how to display the data other than using this kind of code?

foreach($query as $row){
echo $row->student_id;
}

any other than this coz the query only have one row
any way that can i access the returned array like this?

$query['student_id'];
  • 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-23T00:29:32+00:00Added an answer on May 23, 2026 at 12:29 am

    let’s say your table have the following fields

    student_id and student_name
    

    have your model or controller return only one row.

    function get_first_student() {
    
        $query = this->db->select('*')->from('student')-where('student_id','1')->limit(1);
        $data['stuff'] =  $query->row_array(); // or $query->row() which returns an object
        $this->load->view('whatever',$data)
    
    }
    

    then in your view

    <p>student name: <?= $stuff['student_name'] ?> </p>
    <p>student id: <?= $stuff['student_id'] ?> </p>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

lets say i have this query SELECT tags FROM myTABLE; and the result of
Let's say I have this query: select * from table1 r where r.x =
Let's say I have something like this: $db=new PDO($dsn); $statement=$db->query('Select * from foo'); while
Lets say I have the following query. SELECT stringdata FROM table ORDER BY FIELDS(
Lets say I have some code like: ExampleDomainContext ctx = new ExampleDomainContext(); var query
Lets say I have the query: SELECT Foo FROM Bar Which returns Foo A
I do an import data from a query I created in MS Query. Lets
lets say i have a background worker in a class that perform db query
Hey, Lets say we have a query which generates list of city names as
Here is a silly question. Lets say I have a query that produces for

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.