Loop to insert into database


#1

I have a form that will display a brief description of a topic and
provide links (1 to many) for that topic. So I currently have two
tables Articles and Links. I also some stuff on the form that will add
links to the form so that you can create as many was you would like.
The problem I am having is finding out how to submit each link to the
databasen and aligning those links to the articles.

What do you recommend?


#2

Seth B. wrote:

I have a form that will display a brief description of a topic and
provide links (1 to many) for that topic. So I currently have two
tables Articles and Links. I also some stuff on the form that will add
links to the form so that you can create as many was you would like.
The problem I am having is finding out how to submit each link to the
databasen and aligning those links to the articles.

What do you recommend?

After reading that even I was confused and I wrote it.

I have a form that is taken these fields:

in_your_classroom:
title
description
publish_date

in_your_classroom_links
title
url
description

Each IYC feature can have 1 to many links. I have a link that will add
a new set of form fields for an extra link. currently I have each form
field set like this:

<%= text_field “in_your_classroom”, “title[]” %>
<%= text_field “in_your_classroom”, “url[]” %>
<%= text_area “in_your_classroom”, “description[]” %>

I want to loop through each link and add them to my database. What is
the general practice when doing this?

Thanks.

Seth