Jump to content

Selecting firstName, LastName or Both (newbe)


webber82

Recommended Posts

Hi, My question is very easy but i not understand,

i have table with firstname, middlename and lastname, some time the firstname contain the whole name and the middle name and last name empty, some time last is empty and the other two contain name and in some time the middlename is empty and only the firstname and lastname contain the name in the table.

 

Now my question is if i pass a variable "$name" which contain the total name then how i search through table for the required name under the describe situation.

 

 

thanks

Link to comment
Share on other sites

My query is like this

 

<?php

$result = mysql_query("SELECT * FROM members WHERE fname='$name' OR mname='$name' OR lname ='$name');

?>

 

but it not return the result in some casese $name contain the whole name and and the three fields fname, mname and lname contain the parts but in some cased the mname and/or lname are empty due to which its give the error.

 

Thanks for the time.

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.