Database table
id | title | reading | writing | speaking
form.blade.php
<table><tr>
<th>Language</th>
<th>Reading</th>
<th>Writing</th>
<th>Speaking</th>
</tr>
<tr>
<td>
<input name="TitleText_1" id="TitleText_1"/></td>
<td>
<select name="ReadingText_1" id="ReadingText_1">
<option value="High">High</option>
<option value="Medium">Medium</option>
<option value="Low">Low</option>
</select>
</td>
<td>
<select name="langWrittingText_1" id="WrittingText_1">
<option value="High">High</option>
<option value="Medium">Medium</option>
<option value="Low">Low</option>
</select>
</td>
<td>
<select name="SpeakingText_1" id="SpeakingText_1">
<option value="High">High</option>
<option value="Medium">Medium</option>
<option value="Low">Low</option>
</select>
</td>
</tr>
<tr>
<td>
<input name="TitleText_2" id="TitleText_2" /></td>
<td>
<select name="ReadingText_2" id="ReadingText_2">
<option value="High">High</option>
<option value="Medium">Medium</option>
<option value="Low">Low</option>
</select>
</td>
<td>
<select name="WrittingText_2" id="WrittingText_2">
<option value="High">High</option>
<option value="Medium">Medium</option>
<option value="Low">Low</option>
</select>
</td>
<td>
<select name="SpeakingText_2" id="SpeakingText_2">
<option value="High">High</option>
<option value="Medium">Medium</option>
<option value="Low">Low</option>
</select>
</td>
LanguageController.php
$languages = Language::create(array
(
'title' => $input['TitleText_1'],
'reading' => $input['ReadingText_1'],
'writting' => $input['WrittingText_1'],
'speaking' => $input['SpeakingText_1'],
$languages->save();
));
I want what will be the controller code to save into the database. as there are multiple inputs of same label.
How to get all the inputs in controller? Also how to save multiple inputs into database of same column? I am a newbie of Laravel 4.2.
Use multiple inputs with same name like this
This way the data will be posted in the form of an array. Assuming that all the inputs/select are required to be filled by the user
In your controller you can do something like this
Hope this helps.