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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:25:11+00:00 2026-05-22T12:25:11+00:00

I want to display both the user table and users_profiles table in 1 table

  • 0

I want to display both the user table and users_profiles table in 1 table :
I want to link them both so that usrpID = usrID,

Before this process I tried displaying only users table using this code and it works great.

Controller:

$data['query'] = $this->db->query('SELECT * FROM users_profiles');
$this->load->view('users/users_view',$data);

View:

<?php foreach($query->result_array() as $row): ?>
        <tr class="even gradeC">
            <td><?php echo $row['usrID']</td>
            <td><?php echo $row['usrName'];?></td>
        </tr>
<? endforeach; ?>

but when I try to join two tables, it returns me an error: this is my code

$this->db->select('users.usrID, users_profiles.usrpID');
$this->db->from('users', 'users_profiles');
$this->db->join('users', 'users.usrID = users_profiles.usrpID');
$result = $this->db->get();

users table has fields like username,password, etc. and every user has his own profile in users_profiles table

users           users_profiles

users tableusers_profiles table

EDIT I tried selecting the fields but when I tried this

<td><?php echo $row['usrID'];?></td>
            <td><?php echo $row['usrName'];?></td>
            <td><?php echo $row['usrpFirstName'].' '.$row['usrpLastName'];?></td>
            <td><?php echo $row['usrpBday'];?></td>
            <td><?php echo $row['usrpSex'];?></td>
            <td><?php echo $row['usrpAddress'];?></td>    

it returns me the first value in users profiles in which it should not

  • 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-22T12:25:11+00:00Added an answer on May 22, 2026 at 12:25 pm

    users table was in both from and join functions, so in sum you were joining 3 tables: users, users and users_profiles -> the 2 first have the same name -> error unique/alias table.

    Try this (joining [users in from] on [users_profiles in join]):

    $this->db->select('users.usrID, users_profiles.usrpID')
             ->from('users')
             ->join('users_profiles', 'users.usrID = users_profiles.usrpID');
    $result = $this->db->get();
    

    EDIT:

    example:

    To get users_profiles userpNick column:

    $this->db->select('users.usrID, users_profiles.userpNick')
             ->from('users')
             ->join('users_profiles', 'users.usrID = users_profiles.usrpID');
    $query = $this->db->get();
    

    view:

    <?php foreach($query->result() as $row): ?>
            <tr class="even gradeC">
                <td><?php echo $row->usrID</td>
                <td><?php echo $row->userpNick;?></td>
            </tr>
    <? endforeach; ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to display the TIME field from my mysql table on my website,
I want to display a thumbnail image in a cell of tableViewController , this
I currently have a user control that is used on both an /Address/Edit and
I want to display tabular type data, but it will not be coming from
I want to display dates in the format: short day of week, short month,
i want to display some information in a listview using the GridView. i have
I want to display the current host and database names in a view. Where
I want to display some WPF elements near to the selected item of a
I want to display an image within a scroll area. The view port of
I want to display the infinity symbol using CGContextSelectFont(context, HelveticaNeue, textSize, kCGEncodingMacRoman); CGContextShowTextAtPoint(context, myCenter.x,

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.