Jump to content

Recommended Posts

Hi all

I have a search form on my website which lets you search for a buddy, the search can be proformed as a name search using there first name, for example

David


The form then goes to the php page and does a query on what has been typed in, it then sorts the results by the persons surname, for example

David Adams
David Holmes
David Waferry

The query I currently perform is

[code]
$usql = "SELECT * FROM users WHERE `firstname` = '$fname' ORDER BY surname ASC";
$ushow = @mysql_query($usql,$connection) or die(mysql_error());

while ($urows = mysql_fetch_array($ushow)) {

print $urows['firstname'];
print " ";
print $urows['surname'];
print "<br><br>";

}
[/code]

What I want to now do is to offer a surname search box on the same form, what should happen when someone sdoes a search under firstname and surname it would return back all results that match JUST the firstname (like it currently does). What I want to do though, it to show the people who matched the surname at the top of the results and then show just the people who matched the firstname below.

The firstname input box on the search form is called "firstname" and the surname one which I want to add will be called "surname".

Is this at all possible?

Loads of thanks in advance

Ed
Link to comment
https://forums.phpfreaks.com/topic/13404-php-order-by-help/
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.