Repeat database inserts depending on select value


Thats what I’ve already done (see #2 on the image)
The $post.sd_feq is the amount of days it should add on but it does not.

No, that’s not what you have done.
You added some post.sd_feq in the date add formatter, which is wrong.
Just follow my explanation please!

must only be used as a repeater expression, as i already explained in previous posts.

awesome, that’s done it.
so just for my knowledge how does the #$index work for the select number?

You have the repeat, which repeats X times. The $index, returned by this repeat step starts from 0 and increments by 1 on each repeat.

ah ha and the penny drops. Great job thanks buddy

So have found a little issue, the $index works week when its daily, however if I go to weekly (+7days) or bi weekly (+14days) this still does not work.
Is there a way to get the add date to add on the posted value from the form?

I don’t really understand what is not working, sorry.
Can you please explain this more detailed?

The $index of the repeat will return values from 0 to … whatever number it is set to repeat. If it is 7 days, then it will return 0, 1, 2, 3, 4, 5, 6 if it is 20 it will return 0, 1, 2 ..... 19

OK, I’ll try and explain it better for you:

  1. Enter a competition date
  2. select if it is a single date or a repeated date
  3. If its a repeated date then the options comes up to input;
    a. How many times to repeat it
    b. Select if it is a daily, weekly or bi-weekly repeat. - this is where I need to add the days on (for example if the start date is 19/12/19 and its repeated 2 times weekly then it should enter 19/12/19, 26/12/19 & 2/1/20)

On the add days I somehow need to have the number that comes from the posted select value and not the #$index.
Does that make better sense?

Well Peter, this is a totally different logic then.
I am not sure if you understand how the repeater step works. It repeats as many times as the value passed to it is. 2 means - repeat the insert 2 times, 7 means - repeat the insert 7 times.

The repeat step does not know that you want to insert two values with a difference of 7 days.

You probably want to add some conditions in the server action to check this and adjust the insert per your needs.

I’ve got the repeat working no issues…
The problem I am having now is when the date is inserted I need it to add the additional days from the select value.
I’m adding the date through the $post and then in data format I need to add (X) amount of days to the date…

Hi, managed to work it out and here’s how I did it.
Before repeat add session for ($post_date)
In repeat
Add insert for the ($post_date) and other info
Added a query on the previous inserted id
Set session for (date + however many day)

repeated this step for the different add days that I wanted and its all working well :slight_smile: