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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T04:49:09+00:00 2026-05-19T04:49:09+00:00

I have a problem with an array that is getting returned from a query

  • 0

I have a problem with an array that is getting returned from a query I am running,

    $jobs = array(
  array('id'=>2,'salary'=>27000,'benefits'=>'false','benefits_description'=>'','skills'=>'PHP mysql javascript','job_summary'=>'Developing stuff','job_description'=>'Developing stuff','tags'=>'PHP, mysql, web development, web, leeds','created_at'=>1294871124,'updated_at'=>0,'job_titles_id'=>1,'locations_id'=>1,'employers_id'=>4,'id'=>1,'jobtitle'=>'Website Developer','id'=>1,'location'=>'Leeds')
);

I wanting to use the first id in my link I am building, however instead of 2 it is returning 1 as I assume that the first id is getting overwritten by ID’s later in the array? Is there any way to stop this happening, I cannot change my database schema at this stage of the project, the query that gets this from the database looks like this,

$this->db->select('*')
        ->from('jobs')
        ->join('job_titles', 'job_titles.id = jobs.job_titles_id', 'left')
        ->join('locations', 'locations.id = jobs.locations_id', 'left')
        ->where('jobs.employers_id', $employer_id);

        $query = $this->db->get();

        return $query->result_array();
  • 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-19T04:49:10+00:00Added an answer on May 19, 2026 at 4:49 am

    You need to alias the field you’re getting back from the database.

    You’ve not specified what RDBMS you’re using, but chances are it’s MySQL so instead of using a SELECT * (which is lazy and bad practice to be honest), you should specifiy the fields you specifically require and can alias the second ID field using something of the form:

    SELECT ... <table name>.<field name> AS id_2 ... FROM ...
    

    Here’s the relevant MySQL manual page for more information.

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

Sidebar

Related Questions

I have problem in some JavaScript that I am writing where the Switch statement
Here is my issue. I have an array containing the name of cities that
I have a problem I am trying to tackle that involves a 7 point
Good morning SO, I have a class that contains the following static array: public
I have problem with return statment >.< I want to store all magazine names
I have problem with starting processes in impersonated context in ASP.NET 2.0. I am
I have problem compilin this code..can anyone tell whats wrong with the syntax CREATE
I have problem with ActionLink. I'd like to pass to my ActionLink parameter for
I have problem when I try insert some data to Informix TEXT column via
I do not have problem as such but I am quite new to Ruby.

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.