Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
jiri.pekhart
Starting Member
3 Posts |
Posted - 2007-08-02 : 14:03:58
|
| User picks the colors he likes and submits to a page "process.asp"A unique user_ID (from a hidden field) is submitted with the checked checkboxes as well. The checkboxes are generated dynamically from a table tbl_colors that stores the color_ID, color_Name .. etc)Now the page "process.asp"<%= request.form("color_ID") %> writes values of all checked checkboxes like: 1,2,3, (in case the user has checked the first 3 boxes)and<%= request.form("user_ID")%> writes 5,5,5,5,5 (in case the user_ID = 5 and it doesn't matter how many colors the user has picked)I need to store the data into a table called tbl_Users_Colors. It is a linking table with no primary key. It just records the user_ID and color_ID from our form, and handels them as a foreign key linking to tables: tbl_Users and tbl_Colors with one to many relationship.This way I can retrieve what colors have been picked by one user and what users are associated with particular color...THE PROBLEM is that the data can't be stored in multiple rows in the table tbl_Users_Colors.As soon as more than one checkbox is selected, I get the error message that the number of values doesn't fit the table.If the user checks just one, it works fine. I need to store the data into multiple rows like this:tbl_Users_Colors:column ........ columnUserID ........ ColorID... 1 ............... 2... 1 ............... 4... 1 ............... 5 (When eg. user with user_ID=1 has checked colors 2,4,5) I've been trying to loop the INSERT statement, but it doesn't seem to work. Could someone offer a solution? I have been searching the web and found many people asking the same Q. But there was no straight forward answer or tutorial how to do it. I use ASP, MS SQL 2005 and Dreamweaver 8I believe that more people than just me would be interested in a solution of a problem like this. Thanks for checking out and possibly helping with this problem.Jiri. |
|
|
dinakar
Master Smack Fu Yak Hacker
2507 Posts |
|
|
|
|
|
|
|