通过选择选项更新ID

选择其他名称或大小时,我尝试更新披萨ID。这些是从数据库中列出的可用选项,因此毫无问题,但是当按下“提交”按钮时,我收到错误消息“ where子句中的“未知名称”的“披萨名称””,该名称始终是最后一个选项名称。

因此,这些是列出的选项:

<td class="lekerdezes_oszlop">
            <?php 

            $sql_select_2 = "SELECT DISTINCT(etel_nev) FROM etelek ORDER BY etel_id";

            $result2 = $conn->query($sql_select_2);

            echo "<select name=etel_nev>";
            echo "<option value=$row[etel_nev]>- $row[etel_nev] -</option>"; 
            foreach ($conn->query($sql_select_2) as $row2){

            echo "<option value=$row2[etel_nev]>$row2[etel_nev]</option>"; 

            }

            echo "</select>";

            ?>
        </td>

<td class="lekerdezes_oszlop">
            <?php 

            $sql_select_3 = "SELECT DISTINCT(etel_meret) FROM etelek ORDER BY etel_id";

            $result3 = $conn->query($sql_select_3);

            echo "<select name=etel_meret>";
            echo "<option value=$row[etel_meret]>- $row[etel_meret] -</option>"; 
            foreach ($conn->query($sql_select_3) as $row3){

            echo "<option value=$row3[etel_meret]>$row3[etel_meret]</option>"; 

            }

            echo "</select>";

            ?>
        </td>

和更新本身:

if (isset($_POST['rendeles_id'])) {

$sql_update_2 = "UPDATE rendeles 
                SET etel_id =  (SELECT etel_id FROM etelek WHERE etel_nev = $row2[etel_nev] AND etel_meret = $row3[etel_meret])
                WHERE rendeles_id = '" . $_POST['rendeles_id'] . "'";


    if ($conn->query($sql_update_2) === TRUE) {
            echo "<p class='siker_uzenet'>Sikeres adatfrissítés</p>";
        } 
        else {
            echo "<p class='hiba_uzenet'>Hiba az adatok frissítésében: </p>" . $conn->error;
        }

}