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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T19:27:41+00:00 2026-06-05T19:27:41+00:00

I am trying to retrieve a column from another related table, and display that

  • 0

I am trying to retrieve a column from another related table, and display that instead of the ID number thats associated in the index view pages.

Tables:

users: id, username, email
fillups: user_id, vehicle_id, mileage, fillup_date, cost, gallons
vehicles: make, model, color, vehicle_id

When viewing fillups/index you see a list of Fillups, which have the id # associated with each user and vehicle.. i want it to say the username, and make of the vehicle instead (this are columns in the tables). I got this similarly to work in create/edit but that was just showing ALL vehicles for a specific user..

I can’t find in the documentation how to do this, i know it deals specifically with the ORM. not sure though..

Screen capture of the index view page

Currently Vehicle ID pulls from the Fillups.vehicle_id column, it needs to be changed to pull from the Vehicles.vehicle_name column..

enter image description here

  • 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-05T19:27:42+00:00Added an answer on June 5, 2026 at 7:27 pm

    I answered my own question… by associating a has_many and belongs_to in the models i was able to call the vehicle_name in the view.

    in my fillup model i added:

    protected static $_belongs_to = array('vehicle');
    

    in my vehicle model i added:

    protected static $_has_many = array('fillups');
    

    in my view i then could call the vehicle name in the foreach loop like so:

    echo $fillup->vehicle->vehicle_name;
    

    I did the same thing for username in place of user_id

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

Sidebar

Related Questions

I am trying to retrieve the largest number from a varchar column that includes
I'm trying to retrieve records from table by knowing the date in column contains
I'm trying to retrieve books from one table and left join the chapters table.
I’m trying to select various table and column names from a (SQL Server 2008)
I am trying to retrieve results from a SQlite table, and then assign them
I'm trying to retrieve the VideoCollection items from the database, but getting {Invalid column
I found problem when trying to retrieve specific name column that using syntax/statement/command using
I'm trying to retrieve all of the keys from a DynamoDB table in an
//hi i am trying to retrieve the data from database and display in my
I'm trying to retrieve columns based on their corresponding key. Select * from diamond

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.