RE: [PHP] Link only active letters in alphabetical search
| From: | Jay Blanchard | Date: | Thu, 08 Jul 2004 18:14:50 +0000 |
| Subject: | RE: [PHP] Link only active letters in alphabetical search | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-189988@lists.php.net to get a copy of this message | ||
[snip]
currently each letter is hyper linked but i'd like to only link the
letters that have an occurrence in the database. in other words, if
there are no products in the database that start with the letter 'Z'
then i don't want it to have a hyper link.
[/snip]
Do it with SQL
SELECT DISTINCT(SUBSTRING(
productName, 1, 1)) FROM productTable
will give you only one of each of the starting letters that actually
occur in your database.