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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:18:00+00:00 2026-05-26T16:18:00+00:00

I am trying to allow the user to create a shortlist, however I add

  • 0

I am trying to allow the user to create a shortlist, however I add one thing the shortlist, and it overwrites the whatever else is in there, what am I doing wrong?

function validate_add_cart_item($id){

    $this->db->select('candidates.candidate_id, candidates.first_name, candidates.surname, candidates.DOB, candidates.talent, candidates.location, candidates.availability_order, candidates.availability, candidates.availability_comments, candidate_assets.url, candidate_assets.asset_size')
    ->from('candidates')
    ->join('candidate_assets', 'candidate_assets.candidates_candidate_id = candidates.candidate_id', 'left')
    ->where('candidate_assets.asset_size', 'small')
    ->where('candidate_assets.asset_type', 'image')
    ->where('candidates.candidate_id', (int)$id)
    ->limit(1)
    ->order_by('candidates.availability_order', 'DESC');

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

    //die($this->db->last_query());
    // Check if a row has been found
    if($query->num_rows > 0 ){
        foreach ($query->result() as $row)
        {
            $data = array(
                'id'      => $id,
                'name'    => $row->first_name." ".$row->surname,
                'location' => $row->location,
                'talent' => $row->talent,
                'image'  => $row->url
            );

            $this->session->set_userdata('shortlist', array($data));
            return TRUE;
        }

    // Nothing found! Return FALSE! 
    } else {
        return FALSE;
    }
  • 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-26T16:18:01+00:00Added an answer on May 26, 2026 at 4:18 pm
       foreach(...){
          // ...
         $this->session->set_userdata('shortlist', array($data));
       }
    

    You are overwriting your previous userdata several times. Instead of this you should create an array, and call set_userdata once.

      $udata = array();
      foreach(...){
        // ...
        $udata []= $data;
      }
      $this->session->set_userdata('shortlist', $udata);
    

    edit:

    And your query returns only one row, you probably want to update your array, not overwrite it, so something like this:

      $udata = $this->session->get_userdata('shortlist');
      foreach(...){
        // ...
        $udata []= $data;
      }
      $this->session->set_userdata('shortlist', $udata);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I'm trying to add some ability to my project to allow user-defined properties
I am trying to create a Flash application which will allow a user to
I am trying to create a simple dialog box to allow my user to
I'm trying to create a multilevel search to allow user to refine the same
I'm trying to write an application that will allow a non-administrator user to create
I'm trying to create an app in Visual Basic that will allow a user
I am trying to create an asp.net web form that allows a user to
I'm trying to create a user control that allows users to make something like
I've been trying to create a client side editor which allows the end user
I trying to pomp showPermissionDialog for allow the user to post something in a

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.