Skip to content
Advertisement

Laravel AJAX: insert with loop (looping DB table row)

I’m new in Laravel and Ajax, and I have working code (see below).

I have 2 tables, criteria and rating.

I want to query first the table named:criteria like (select * from criteria where level = 1), then using the result, I want to save multiple rows in “ratings” using some field of query result + some input variable from user.

Like this:

JavaScript

Existing Ajax:

JavaScript

Existing Controller:

JavaScript

Advertisement

Answer

You can just use a count() method instead of length.

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement