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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T16:01:50+00:00 2026-06-01T16:01:50+00:00

I am just grabbing user data from a few tables but users have the

  • 0

I am just grabbing user data from a few tables but users have the option of adding more than one skill or exp.

$query_str = "SELECT a.*, b.*, c.*, d.*, e.* FROM edu a
              JOIN exp b ON a.user_id=b.user_id
              JOIN user_profiles c ON a.user_id=c.user_id
              JOIN skills d ON a.user_id=d.user_id
              JOIN comp e ON a.user_id=e.user_id
              WHERE a.user_id = ?";

$query = $this->db->query($query_str, $end_user);
            if($query->num_rows() > 0) {
                    foreach($query->result_array() as $stuff) {
                            $data[] = $stuff;
                    }
                    return $data;
                    } else {
            return false;
                    }

Everything is fine until I try to display the data. If a user has two exp, everything else is showing up twice. I m not sure how to write this. Would it be easier to do separate them? One query for each item?

public function get_education()
    {
           $one_edu = $this->test_model->one_edu($end_user);
            if ($one_edu != false)
            {
                    foreach($one_edu as $edas) {
                            $one_edu_html .='<p>'.$edas['objective'].'</p>';
                    }

                    foreach($one_edu as $exp) {
                            $one_edu_html .= '<p>'.$exp['exp_title'].'</p>';

                    }

                    foreach($one_edu as $educ) {
                            $one_edu_html .= '<p>'.$educ['edu_title'].'</p>';
                    }

                    $result = array('status' => 'ok', 'content' => $one_edu_html);
                    echo json_encode($result);
                    exit();
            }else{
                    $result = array('status' => 'ok', 'content' => '');
                    echo json_encode($result);
                    exit();
            }
    }

Now it s returning something like this:

Objective
Exp title1
Exp title2
Edu title
Edu title <- Extra

Using codeigniter

  • 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-01T16:01:51+00:00Added an answer on June 1, 2026 at 4:01 pm

    The main reason for this is because you haven’t grouped your rows. Add a grouper, like GROUP BY a.id at the end


    Update

    The rows are duplicating because they are different, you can group the field on a single rows, using GROUP_CONCAT

    SELECT a.user_id, a.education, GROUP_CONCAT(a.edu_title SEPARATOR ",") "Edu_Title", GROUP_CONCAT(b.exp_title SEPARATOR ",") "Experience Title" ,b.experience, c.objective, d.skill, e.comp FROM edu a
    JOIN exp b ON a.user_id=b.user_id
    JOIN user_profiles c ON a.user_id=c.user_id
    JOIN skills d ON a.user_id=d.user_id
    JOIN comp e ON a.user_id=e.user_id
    WHERE a.user_id = 243;
    

    Demo

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

Sidebar

Related Questions

Rather than just grabbing the user's friends' emails, I want to show their list
I have a python script that is constantly grabbing data from Twitter and writing
Just switched over from eclipse to vs 2008 for debugging javascript, i feel more
I have a table with a few relational columns and one XML column which
I have a mysql statement which grabs just one record based on an id.
I am working on doing some data transfers moving data from one database to
I have an iPhone app which submits user entered data to a SQL database.
Just wondering how I can make my app open automatically at login, but make
Just out of curiosity, how does iostream access the input-output system. (I have a
I have a webpage that fires off an Ajax request which stores some data

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.