I mean, when selecting from the database, and ordering by the title of things.
So that it goes like
Allen
alex
benny
brad
frank
george
lenny
paul
tim
theresa
thimble
zoe
Okay, that's what it does currently.
but if you put "the aaa" and "the bbb"
it would end up like this
Allen
alex
benny
brad
frank
george
lenny
paul
tim
the aaa
the bbb
theresa
thimble
zoe
I want it to do like this
the aaa
Allen
alex
the bbb
benny
brad
frank
george
lenny
paul
tim
theresa
thimble
zoe
I've searched this, messed with this, couldn' figure it, couldn't find it anywhere. I'm stuck.
I need major help on doing this, thanks.
Block words
Started by pirateXcore, Aug 20 2006 07:25 AM
4 replies to this topic
#1
Posted 20 August 2006 - 07:25 AM
#2
Posted 20 August 2006 - 08:58 AM
I'm assuming you're using PHP/MySQL to do this, in which case, MySQL doesn't have a built-in feature of alphabetizing without the "the." It would be nice if it did.
Which means, the only way you're going to have to pull all the database values and use php to alphabetize them yourself.
You could also just add the names with "the" in the title like this:
aaa, the
bbb, the
Instead of how you were doing it.
Unless you're deadset on showing them the way they are there, I suggest the easy way out
Which means, the only way you're going to have to pull all the database values and use php to alphabetize them yourself.
You could also just add the names with "the" in the title like this:
aaa, the
bbb, the
Instead of how you were doing it.
Unless you're deadset on showing them the way they are there, I suggest the easy way out
Edited by Wolfe, 20 August 2006 - 08:58 AM.
#3
Posted 20 August 2006 - 09:58 AM
you would have to get the info from mysql and put it into an array (hehe... ironic?) then use sort() to display it... i'll look into it and see if i can come up with something
or maybe someone will reply before i even get started?!
or maybe someone will reply before i even get started?!
Edited by coolaid, 20 August 2006 - 09:58 AM.
#4
Posted 20 August 2006 - 11:04 AM
function replaceThe($string){
$string = str_replace('the ', '', $string);
return str_replace('The ', '', $string);
}
$array = array_map('replaceThe', $results);
array_multisort($array, SORT_ASC, SORT_STRING, $results);
print_r($results);
Idea stolen from php.net (again). If it doesn't work, it's not my fault, i haven't tested it. It should work though.
Edited by rc69, 20 August 2006 - 11:04 AM.
#5
Posted 21 August 2006 - 12:11 AM
I've got one word to say, and it's not good.
Thanks for that though, i'll see if I can get it figured out. XD
Thanks for that though, i'll see if I can get it figured out. XD
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users
