I have a select option in foreach loop. In every loop I'm creating a div and inside div a select option. But problem is when I send select's value with post method I can't get option's correct posted value. For foreach first 2,3 item button is working and submitting form but when I try to submit other items' form button is not working I can't create unique name for select because I must assign post variable to a variable in action page.
I think problem is about unique select name="", I can't give an unique name to select because I need it's name in action page as you know. How can I solve this stupid thing.?
<?php
foreach($a as keywords_arr){
?>
<form name="<?= $keywords_arr["keyword_id"]?>" method="post" action="actions/myaction.php">
<div class="modal-body">
<label for="tagler">Bla bla</label>
<select name="tagler" style="width: 100%;" class="form-control">
<?php
$all_tags = $db->query("SELECT *****");
$all_tags->setFetchMode(PDO::FETCH_ASSOC);
$all_tags_arr = $all_tags->fetchAll();
foreach ($all_tags_arr as $tag) {?>
<option value="<?= $tag["tag_id"] ?>"><?= $tag["tag_name"] ?></option>
<?php } ?>
</select>
<input type="hidden" name="kw_id_label" value="<?= $keywords_arr["keyword_id"] ?>"/>
<br><br>
<span id="result_lbl_"></span>
</div>
<div class="modal-footer">
<button id ="btn_<?= $keywords_arr["keyword_id"] ?>" type="submit">Save</button>
</div>
</form>
<?php}?>
myaction.php page
<?php
$tag = $_POST["tagler"];
$keyword_id = $_POST["kw_id_label"];
?>
Fiddle example:See example