Hi people,
I have a list of band names and solo artists names.
Currently the band names that start with 'The' are sorted so the 'The' is displayed after the other words in the band name and then listed alphabetically.
This is done using this query:
$query = "SELECT *,
IF(Band LIKE 'The %', CONCAT(SUBSTRING(Band, 5), ', The'), Band) AS list_item
FROM BandNames
ORDER BY list_item";
Now I want to display solo acts for example: Elton John, as John, Elton. I have done this using like this:
if ($Solo == 'yes') {
$SoloExploded = explode(' ', $Band);
$NumWords = count($SoloExploded);
$LastWord = $SoloExploded[$NumWords-1];
echo $LastWord.', ';
for($i=0;$i < $NumWords-1;$i++) {
echo $SoloExploded[$i].' ';
}
}
else {
echo $Band;
}
Trouble is, by doing it that way, I have forgot that the list will no longer be alphabetical, which is the reason I'm here.
I wondered, is there a way to do what I did with the Solo Acts, but within the MySQL Query?
Or is the only way of achieving this, by reading all the band names and solo names into an array and then arrange that alphabetically?
Thanks.
Note: My host only has MySQL 4.0.27 installed.