I'd just get it over with and make first_name and last_name fields in your
table. It will be so much easier to sort by last name that way. I do it
this way everytime. It won't take much time to implement either.
Captain Jack Communications
----- Original Message -----
From: "Jason Soza" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, May 06, 2002 2:25 PM
Subject: [PHP] Sorting, sort of
> I have a 'name' field in a MySQL table that contains people's first and
> last names, i.e. "John Smith" - but some people may choose not to
> include their last name, so they're just "John" in the table, or they
> may choose to include themselves and someone else, but not the last
> name, "John and Jane".
> I'm thinking the easiest way to sort by last name, which is what I want
> to do, is to just go into MySQL and make 'first_name' and 'last_name'
> fields, but if there's a way to do this with PHP that'd be great, so
> then I wouldn't have to mess with the table and data.
> Anyhow, I've looked up sort() and asort() in the PHP manual, but I'm
> not sure how I'd go about this. I assume I'd use some kind of function
> to read the 'name' field to the first space, take what it finds after
> the space and put it into an array, then have some if/else statement to
> deal with the lack of a space or the presence of multiple spaces, then
> use sort() on that array.
> Just looking for some guidance, maybe a specific function or bit of
> code. Anything that'd help. Or if this would be more easily addressed
> by reconfiguring my MySQL table, just let me know.
> Jason Soza
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php