Hi all,
I have a form where users have to provide a ranking for 10 items.
Each row of the form is a drop-down menu that contains anywhere from
5 to 20 items. Each row writes data to the same fields: itemName and
itemRank. The values of itemName and itemRank come from each separate
drop-down menu. The value of itemRank is incremented by 1 in each of
the ten drop-down menues, so that for menu 1 the value of itemRank is
1, for menu 2 the value of itemRank is 2, and so on. If some
positions do not get an item, they get the default value in the
drop-down menu (which is "none"), and no INSERT is processed for that row.
What I have so far is 10 separate INSERT queries, one for each row, as follows:
<cfif isDefined("FORM.rank1") AND FORM.rank1 NEQ "none">
<cfquery datasource="ranking_dsn">
INSERT INTO rank_tb (itemName, itemRank)
VALUES (#itemName1#, #itemRank1#)
</cfquery>
</cfif>
<cfif isDefined("FORM.rank2") AND FORM.rank2 NEQ "none">
<cfquery datasource="ranking_dsn">
INSERT INTO rank_tb (itemName, itemRank)
VALUES (#itemName2#, #itemRank2#)
</cfquery>
</cfif>
....and so on.
My question is: what other (more elegant) ways could you think of to
achieve the same results (i.e., multiple entries to the same table fields)?
I'd appreciate ideas, pointers, and suggestions.
Regards,
Roberto Perez
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:232781
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54