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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T05:15:13+00:00 2026-05-18T05:15:13+00:00

So i have this PM system. At the recipient field, You can type in

  • 0

So i have this PM system.

At the recipient field, You can type in the full name of who you want to write to.

So I want to help the user alittle, if he don’t remember the name.

So if you want to write the full name “Megan Fox” and only know:

Megan
Megan F
Megan Fo
Meg Fo
M Fox
etc..

It will return “Did you mean Megan Fox?” This already works fine.

Now what I need In this is that if you write only Fox , with no firstname, i want it to echo “Did you mean Megan Fox?”

Here’s where Im stuck, as it creates $lastname after the space. And i really don’t want to use two fields for first and last.

How can I do that?

Here’s my code:

list($firstname, $lastname) = array_map('ucfirst', explode(' ', $mot, 2));
$qur = mysql_query("
 SELECT id, firstname, lastname, 
 (firstname = '$firstname' AND lastname = '$lastname') AS full FROM users 
 WHERE (firstname = '$firstname' AND lastname='$lastname') 
 OR (firstname LIKE '$firstname%' AND lastname LIKE '$lastname%')
 ORDER BY (firstname = '$firstname' AND lastname='$lastname') DESC");
 $get = mysql_fetch_array($qur);

 if($get["full"] == 1){
 echo $get["id"];
 }else{
 echo "Did you mean: ".$get["firstname"]." ".$get["lastname"]." ?";
 }
  • 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-18T05:15:14+00:00Added an answer on May 18, 2026 at 5:15 am

    This should work.

    $qur = mysql_query("
     SELECT id, firstname, lastname, 
     (firstname = '$firstname' AND lastname = '$lastname') AS full FROM users 
     WHERE (firstname = '$firstname' AND lastname='$lastname') 
     OR (firstname LIKE '$firstname%' AND lastname LIKE '$lastname%')
     OR ('$lastname' = '' AND lastname LIKE '$firstname%')
     ORDER BY (firstname = '$firstname' AND lastname='$lastname') DESC");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this system where a client uploads a logo of a company and
I have this code :- using (System.Security.Cryptography.SHA256 sha2 = new System.Security.Cryptography.SHA256Managed()) { .. }
I have this code (C#): using System.Collections.Generic; namespace ConsoleApplication1 { public struct Thing {
I have this web service : using System.Web.Services; namespace Contracts { [WebService(Namespace = http://tempuri.org/)]
I have this line of code: System.Drawing.Icon icon = System.Drawing.Icon.FromHandle(shinfo.hIcon); A few lines later,
I have this simple example: using System; using System.Collections.Generic; namespace ConsoleApplication1 { class Program
I have this external module of my system and I thought to integrate it
I have this error message could not load assembly 'system.data.entity, version 4.2.0.0, culture=neutral,publickeytoken=b77a5c561934e089' or
I have this webdav code thats creating folders in SharePoint: HttpWebRequest request = (System.Net.HttpWebRequest)HttpWebRequest.Create(folderAddress);
I have this piece of code in c#: private static void _constructRow(SqlDataReader reader, system.IO.StreamWriter

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.