[Solved] Update Table if value not exists


There is one problem your not setting value and its empty. By which the values you select wont be added or updated to your database.

The second is you have not given the name to your select dropdown by which even if you select the values it wont be posted to your action.

<form action="update_student.php" method="post">
    <select name="from_class">
        <option value="I">I</option>
        <option value="II">II</option>
        <option value="III">III</option>
    </select>

    <select name="to_class">
        <option value="I">I</option>
        <option value="II">II</option>
        <option value="III">III</option>
        <option value="IV">IV</option>
        <option value="V">V</option>
    </select>

    <input type="submit" value="Upgrade">
</form>

Suggestion:

And even you need to validate that the student must be promoted to the next class and not the class which he is already completed.

Eg: If your upgrading the student from II to III which is totally fine but you must not allow II to I.

In case if the user has asked for this kind of workflow then atleast you must prompt with confirmation for degrading the class from II to I

solved Update Table if value not exists