How do I update a specific row in a table using php form?
<p>Please bear with me, I'm not familiar yet with the language. I have a table that lists an applicant record such as applicant number, name and status. I want to update an applicant status either 'hired' or 'failed' on a specific row using a PHP form. However, I'm not sure how to get the specific submit name on its row upon submission. Or if you have a workaround I would appreciate that. Thank you so much for your help.</p>

<pre><code>&lt;!DOCTYPE html&gt;
&lt;html&gt;
      &lt;h2&gt;Applicant Records&lt;/h2&gt;
&lt;?php

$mysql_hostname = "localhost";
$mysql_user = "root";
$mysql_password ="";
$mysql_database = "applicantrecord";

// Create connection
$conn = new mysqli($mysql_hostname, $mysql_user, $mysql_password, $mysql_database);
// Check connection
if ($conn-&gt;connect_error) {
    die("Connection failed: " . $conn-&gt;connect_error);
} 

$sqli = "SELECT id, firstname, lastname, status FROM applicant";
$result = $conn-&gt;query($sqli);


if ($result-&gt;num_rows &gt; 0) { ?&gt;
    &lt;table class="table"&gt;
    &lt;thead&gt;
        &lt;tr&gt;
            &lt;th&gt;Applicant No.&lt;/th&gt;
            &lt;th&gt;Lastname&lt;/th&gt;
            &lt;th&gt;Firstname&lt;/th&gt;
            &lt;th&gt;Status&lt;/th&gt;
            &lt;th&gt;&lt;/th&gt;
        &lt;/tr&gt;
    &lt;/thead&gt;
&lt;?php
    // output data of each row

    echo "&lt;tbody&gt;";
    while($row = $result-&gt;fetch_assoc()) 
    { ?&gt;
            &lt;tr&gt;
                &lt;td&gt;
                    &lt;?php echo $row["id"]; 
                        $appid = $row["id"];
                    ?&gt;  
                &lt;/td&gt;
                &lt;td&gt;
                    &lt;?php echo $row["lastname"]; ?&gt;
                &lt;/td&gt;
                &lt;td&gt;
                    &lt;?php echo $row["firstname"]; ?&gt;
                &lt;/td&gt;
                &lt;td&gt;
                    &lt;?php echo $row["status"]; ?&gt;
                &lt;/td&gt;
                &lt;td&gt;
                &lt;/td&gt;
                &lt;td&gt;

                        &lt;div&gt;
                        &lt;form action="" role="form" method="post" name="form&lt;?php echo $appid; ?&gt;"&gt;
                        &lt;select name="applicant_status"&gt;
                        &lt;option value="Hired"&gt;Hire&lt;/option&gt;
                        &lt;option value="Failed"&gt;Fail&lt;/option&gt;
                        &lt;/select&gt;

                        &lt;/p&gt;
                        &lt;button type="submit" class="btn btn-default" name = "submit&lt;?php echo $appid; ?&gt;" data-dismiss="modal"&gt;Submit&lt;/button&gt;                     
                        &lt;/form&gt;
                        &lt;?php

                        if(isset($_POST["submit"])){
                            $dbhost = 'localhost';
                            $dbuser = 'root';
                            $dbpass = '';
                            $newappid = $appid;
                            $newapptstatus = $_POST['applicant_status'];
                            $connect = mysql_connect($dbhost, $dbuser, $dbpass);
                        if(! $connect ) {
                            die('Could not connect: ' . mysql_error());
                            }

                        $sql_sub = "UPDATE applicant ". "SET status = '$newappstatus'".  
                                    "WHERE id = '$newappid'" ;
                                    mysql_select_db('applicantrecord');
                        $retval = mysql_query( $sql_sub, $connect );

                        if(! $retval ) {
                        die('Could not update data: ' . mysql_error());
                            echo "&lt;script type= 'text/javascript'&gt;alert('An error occured! Applicant status update failed!');&lt;/script&gt;";
                        }

                        echo "&lt;script type= 'text/javascript'&gt;alert('Applicant status updated successfully!');&lt;/script&gt;";
                        mysql_close($connect);

            }                   
                        ?&gt;
                        &lt;/div&gt;

                &lt;/td&gt;
            &lt;/tr&gt;
    &lt;?php }
    echo "&lt;/tbody&gt;";
    echo "&lt;/table&gt;";
} else {
    echo "0 results";
}
$conn-&gt;close();
?&gt;

&lt;/html&gt;
</code></pre>