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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T23:35:38+00:00 2026-06-16T23:35:38+00:00

Searching a name returns one result when there are several with the same last

  • 0

Searching a name returns one result when there are several with the same last name. It could be the foreach loop but I think its the activerecord statement.

model

public function finduser($name) {

    if ($name == null || $name == '') {
            return false;
    }

    $this->db->select('e.emp_no, e.first_name, e.last_name, t.title, d.dept_no');
    $this->db->from('employees AS e, titles AS t, dept_emp AS d');
    $this->db->where('e.last_name', $name);
    $this->db->where('e.emp_no = t.emp_no');
    $this->db->where('e.emp_no = d.emp_no');

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

    $data = array();

    foreach ($result->result() as $row )
    {
    $entry = array();
    $entry['emp_no'] = $row->emp_no;        
    $entry['first_name'] = $row->first_name;
    $entry['last_name'] = $row->last_name;      
    $entry['title'] = $row->title;
    $entry['dept_no'] = $row->dept_no;

    $data[] = $entry;

    return $data;

}
}

view

if (isset($user)) {
foreach ($user as $res) {

echo "employee id =" .$res['emp_no']; ?> <br> <?php
echo "first name = " .$res['first_name']; ?> <br> <?php
echo "last name = " .$res['last_name']; ?> <br> <?php
echo "title = " .$res['title']; ?> <br> <?php
echo "department no = " .$res['dept_no']; ?> <br><br> <?php  
  • 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-16T23:35:39+00:00Added an answer on June 16, 2026 at 11:35 pm

    Your return is inside the for loop.

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

Sidebar

Related Questions

Searching for values that uses the same value Example SELECT Name, UnitPrice, Quantity, Color
Searching here I found that this question was already asked , but I think
I've been searching like one and a half days but I can't find any
I've tried searching around for an answer, but haven't found one that seems to
How to get all contact numbers for a Contact when searching by contact name.
I have a file and searching mutiple value i.e I need to search {Name,Class}
I am searching for records in a table as follows: SELECT Id, Name FROM
Searching from google.com, like www.abc.com Search Result Rank the pages like Title..... Description... www.abc.com
I'm searching since one week and couldn't find a proper solution for my problem.
After much searching and trials, I am stuck... I have two classes, one is

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.