"hex kid" <he****@hotpop.com> wrote in message
news:f1******************************@news.meganet news.com...
elyob wrote:That's probably a better way then using the PHP method I was thinking of,
although I would want to show a greyed out letter for the substrings that
don't exist ...
e.g. [A] [b] C [D] [E] [F] ...
So here, C is shown but has no href # as there are no towns beginning
with C..
You can create a table with all the letters and join it with the towns
table for a better approach.
select letter, count(town) from letters left join town
on letter=substring(town, 1, 1) group by letter
My test run returned something like this
letter count(town)
A 1
B 1
C 0
D 1
E 1
Now, just go through the result array
printing the link if count(town) != 0
I'm now thinking of moving away from the MySQL approach .. we run multiple
sites all using the same code. This is going to affect all the sites. Some
of the sites are UK only, although the hotel site is worldwide. This extra
table probably isn't what I need when I already hold the details.
I'm now thinking along the lines of holding an array of the standard
alphabet, and probably passing the previous first letter for comparison
purposes throughtout the 'while' loop. If the new letter's not the next
letter in the alphabet, output it, repeat until they match, then output a
link ...
I'm just trying to figure out how this is going to work ...
Thanks for your help so far ..
Nick