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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T03:19:39+00:00 2026-06-02T03:19:39+00:00

I had just finished my search functionality for a users system when I found

  • 0

I had just finished my search functionality for a users system when I found out that it didn’t search the way I wanted it to.

If I have a datebase table with 2 columns called ‘fname’ and ‘lname’.

In one row, ‘fname’ has a value of ‘Ashley’ and ‘lname’ has a value of ‘Staggs’.

I can search for either ‘Ashley’ or ‘Staggs’ and I will get the results correctly, but if I search for ‘Ashley Staggs’, no results are displayed.

How would I do this properly?

My SELECT query is as follows:

SELECT * FROM `users` WHERE fname LIKE '%" . protect($_GET['s']) . "%' OR lname LIKE '%" . protect($_GET['s']) . "%'

I knew something like this would happen, but this time I can’t figure it out.

Thanks,
Ashley

  • 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-02T03:19:43+00:00Added an answer on June 2, 2026 at 3:19 am

    ‘Ashley Staggs’ is neither in fname, nor in lname, so your request doesn’t return anything. You could try to concatenate your MySQL fields:

    SELECT * FROM `users` WHERE fname LIKE '%" . $_GET['s'] . "%' OR lname LIKE '%" . $_GET['s'] . "%' OR CONCAT(fname, ' ', lname) LIKE '%" . $_GET['s'] . "%'
    

    [EDIT] Even better:

    SELECT * FROM `users`
    WHERE REPLACE(CONCAT(fname, lname, fname), ' ', '')
    LIKE '%" . str_replace(' ', '', protect($_GET['s'])) . "%'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just finished creating several models and a had to separately write all of
I have just had a brain block, I have a Deck object and want
I just finished writing a date parser for my ECMAScript implementation. Previously I had
I just finished taking a final exam on web applications. Capping off what had
I have just finished making a flash banner in Fl5 and have embedded it
I have finished the majority of my application that I am working on, but
I just finished a class on InfoPath where the teacher had a grim view
Hi finished doing 3 IT diplomas, I have customer service experience, have just started
I have just finished my latest task of creating an RSS Feed using PHP
I have a paid app that's been out in the Android Market for 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.