> Im in a bind. Admittedly my weakness in cf is complex
> data.
> Im building a car database for someone and they want to be
> able to add
> dynamic options with options in their web admin so they
> can select these
> when adding new cars.
> example.
> color - red, yellow, blue
> interior - cloth, leather vinyl and so on.
> Basically unlimited.
> Whats the easiest way to allow them to add as many options
> with as many
> options for those options into a db to dynamically
> populate a form for
> when they add new cars.
> Hopefully this wasnt a confusing explanation. Its late
> and Ive just
> about given up on figuring this out through books.
Hi Emmet ... Sean's recommendation isn't too bad, although I suspect he may have
misread the question a tad...
I would create 3 new tables as follows:
OPTIONS
- optionid
- optionname
OPTION_ITEMS
- optionid references options.optionid
- optionitemid primary key
- optionitemvalue
CAR_OPTIONS
- carid references cars.carid
- optionid references options.optionid
- optionitemid references option_items.optionitemid
To get the options for the form, select them this way:
SELECT options.optionname, option_items.*
FROM options
LEFT JOIN option_items ON (option_items.optionid = options.optionid)
ORDER BY options.optionname, option_items.optionitemvalue
<cfoutput group="optionid">
<select name="option_#optionid#">
<cfoutput group="optionitemid">
<option value="#optionitemvalue#">
#optionitemvalue#<option>
</cfoutput>
</select>
</cfoutput>
then similarly when pulling data to display for the car, just change the groups a bit
SELECT car.*, options.optionname, option_items.*
FROM car
LEFT JOIN car_options ON ( car_options.carid = car.carid )
LEFT JOIN options ON ( options.optionid = car_options.optionid )
LEFT JOIN option_items ON ( option_items.optionid = car_options.optionid )
ORDER BY options.optionname, option_items.optionitemvalue
<cfoutput group="carid">
<cfoutput group="optionid">
<tr><td>#optionname#</td>
<td>#optionitemvalue#</td></tr>
</cfoutput>
</cfoutput>
Sorry I couldn't provide a more thorough explanation -- it's a bit late here. In any
event, I think you'll find what you're looking for if you read up a little bit on the
group attribute of the cfoutput tag.
hth
s. isaac dealey 972-490-6624
new epoch http://www.turnkey.to
lead architect, tapestry cms http://products.turnkey.to
tapestry api is opensource http://www.turnkey.to/tapi
certified advanced coldfusion 5 developer
http://www.macromedia.com/v1/handlers/index.cfm?ID=21816
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
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
This list and all House of Fusion resources hosted by CFHosting.com. The place for
dependable ColdFusion Hosting.
http://www.cfhosting.com
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4