hello.

in an effort to more easily find products in the cart i'm building
i've given the ability to the user to click a letter from the alphabet
to search for all products whose product id starts with that letter.

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.

i'm writing to the list to share my solution to this problem and
hopefully find a better way to do it (if one exists).

here is my solution:

1. pull a list of products from the database
2. truncate each product id down to it's first letter
3. remove all the duplicates
4. use this list to build the links.

as i loop through the alphabet i will only write a link for those
letters that occur in modified list. everything else will just be a
non-linked letter.

it's a pretty easy solution (concerning the logic behind it) but i
don't know if it's the best one and i haven't been able to come up
with anything else.


thanks,
chris.

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

Reply via email to