I actually asked this same type of question not too long ago. Just separate
the name field into first_name and last_name - it'll be better in the long
run. It's not as hard as it sounds - dump your table, use some program that
will read comma delimited stuff and export as tab-delimited (I used Excel),
separate the first and last names, modify your table to have the correct
columns, clear it, add the data back in (LOAD DATA...)

It may require some modification of your scripts you already have, but
really it's just much cleaner this way. I didn't want to do it simply
because I was lazy and using PHP to do this for me seemed to be the easier
choice. It's not, and doing it that way is far from efficient.

HTH,

Jason Soza

-----Original Message-----
From: John Holmes [mailto:[EMAIL PROTECTED]]
Sent: Sunday, May 12, 2002 1:26 PM
To: 'PHP-General'
Subject: RE: [PHP] help with sort problem


You really want to handle this in your database. If you need data to be
in two fields, first name and last name, then put it in your database
that way. Save yourself some time. How easy is it to just add another
text field in your form, and insert one more variable into the
database???

Whatever kind of "hack" you come up with in PHP is going to be a waste
of time and memory.

---John Holmes...

> -----Original Message-----
> From: Nick Wilson [mailto:[EMAIL PROTECTED]]
> Sent: Sunday, May 12, 2002 9:23 AM
> To: php-general
> Subject: [PHP] help with sort problem
>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hi all,
> I hope someone might help me with a little puzzle...
>
> I have bunch of db results and one of the fields is 'name',
> I want to see if there are 2 parts to it like FirstName LastName and
if
> so order by the last name.
>
> I can see explode() being the php function I need here but am a little
> lost as to what will happen if there is only one word in the name var.
>
> If someone can suggest what I might do that would be great!
> many thanks...
> - --
> Nick Wilson     //  www.explodingnet.com
>
>
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.0.6 (GNU/Linux)
>
> iD8DBQE83pbjHpvrrTa6L5oRAv5XAJsFAXLb0puFyeknXoaGL7rYUHGxVACdHxt8
> ej2/Y56p75z5jZ43DvSbDzo=
> =8rzj
> -----END PGP SIGNATURE-----


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to