You are using square brackets(array) [ ] in your HTML code to define the 'name' attribute as an array 'name="pri[]"', but in your PHP code, you are treating it as a single value '$name= isset($_POST["pri"]) ? $_POST["pri"]: '';'. I am not sure why you are declaring it as an array in your radio element though, as a single value instead of an array will work fine as you only use the string "Primary" at each row...
You need to change your code to handle the array when you submit your form -
<?php
if (isset($_POST["submit"])) {
$lang = isset($_POST["lang"]) ? $_POST["lang"] : array();
$name = isset($_POST["pri"]) ? $_POST["pri"] : array();
for ($i = 0; $i < count($name); $i++) {
echo $name[$i];
}
}
?>
If you should change your radio and text element name values to not be an array, your code will look like the following, which ran fine in my test -
<form method="POST" action="">
<table>
<?php while($row = mysqli_fetch_assoc($result)) { ?>
<tr>
<td><input type="text" name="lang" value="<?php echo $row['lang'] ?>">
<td><input type="radio" name="pri" value="Primary"
<?php if($row['pri'] == "Primary") { echo "checked"; } ?>>
</td>
</tr>
<?php } ?>
</table>
<button type="submit" name="submit">Send</button>
</form>
<?php
if (isset($_POST["submit"])) {
$lang = isset($_POST["lang"]) ? $_POST["lang"] : '';
$name = isset($_POST["pri"]) ? $_POST["pri"] : '';
echo $name;
}
?>
To return only the rows where your user clicked on radio element and it's value was set to "Primary", you can use the following code when your form submit. In my code I will only echo the values, you need to add your code for database table insert accordingly -
<?php
if (isset($_POST["submit"])) {
$lang = isset($_POST["lang"]) ? $_POST["lang"] : array();
$name = isset($_POST["pri"]) ? $_POST["pri"] : array();
for ($i = 0; $i < count($name); $i++) {
if ($name[$i] == "Primary") {
echo "Language: " . $lang[$i] . ", Priority: " . $name[$i] . "</br>";
}
}
}
?>