Sure.. - Generate a random number between 1 and the number of categories. Store that in a var, say "myCatNum". - Generate a random number between 1 and the number of items in the randomly generated category. Store that in a var, say "myItemNum" - Identify (in your db) each category with a number, beginning with 1. - Identify (in your db) each item in a category with a number, beginning with 1. - Create a query that pulls the appropriate item from the appropriate category. Something like:
SELECT whateverfieldyouwant FROM myTable WHERE categorynumber = #myCatNum# and itemnumber = #myItemNum# This, of course, assumes that all items are stored in one table.. Not a table for each category. HTH Lee | -----Original Message----- | From: Scott Wolf [mailto:[EMAIL PROTECTED]] | Sent: Thursday, November 28, 2002 5:16 PM | To: CF-Talk | Subject: Random Item Selection | | | In my database, I have a single table that stores all of the | individual items for sale on my website. I have 20 or so | different item categories and 6 different individual items | for each category. What I would like to do is find a way to | have my frontpage randomly select an item from each category | to display on the front page. I was wondering if anyone | knows of a way to do that. Any help would be greatly | appreciated. Thanks! | | Scott Wolf | http://www.eatshirt.com | | ------------------------------------------------------- | WARNING! Some of the shirts on | eatshirt.com are highly offensive. | This is your official warning. Sure, | you could say that you didn't see | it, but I can prove that I sent it and | that's all that matters legally. You | now have no right to complain about | the site content. :P | ------------------------------------------------------- | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm