SQL仅编辑第一个选项

This is the code from our handle page we are trying to edit our database in phpmyadmin but can seem to only edit our first entry even though we clicked on other entries' edit button

require 'dbfunction.php';
$con = getDbConnect();
$crew_id = $_POST["crew_id"];
$CrewName = $_POST["CrewName"];
$CrewRank = $_POST["CrewRank"];
$StartDate = $_POST["StartDate"];
$EndDate = $_POST["EndDate"];
$PayrollNo = $_POST["PayrollNo"];
$EmployeeNo = $_POST["EmployeeNo"];
$WatchKeeping = $_POST["WatchKeeping"];
$Active = $_POST["Active"];
//$Delete = $_POST["Delete"];

if (!mysqli_connect_errno($con)) {

$queryStr = "SELECT crew_id " .
        "FROM crewlist";
}
$result = mysqli_query($con, $queryStr);
while ($row = mysqli_fetch_array($result)) {
if (!mysqli_connect_errno($con)) {
    $sqlQueryStr = "UPDATE crewlist SET crew_name = '$CrewName', crew_rank = '$CrewRank', start_date = '$StartDate' "
            . ", end_date = '$EndDate', payroll_no = '$PayrollNo'"
            . ", employee_no = '$EmployeeNo', watchkeeping = '$WatchKeeping', active = '$Active' WHERE crew_id = " . $row['crew_id'];

    mysqli_query($con, $sqlQueryStr);

    mysqli_close($con);
} else {
    break;
}
header('Location: crewlisting.php');
}

?>

This code only edits the first entry of our database and the rest remains stagnant. This is the code from our edit page

<?php
            if (!mysqli_connect_errno($con)) {

                $queryStr = "SELECT * " .
                        "FROM crewlist";
            }
            $result = mysqli_query($con, $queryStr);
            while ($row = mysqli_fetch_array($result)) {

                echo "<tr>.<th>" . $row["crew_name"] . "<br></br>" . "</th>";
                echo "<th>" . $row["crew_rank"] . "</th>";
                echo "<th>" . $row["start_date"] . "</th>";
                echo "<th>" . $row["end_date"] . "</th>";
                echo "<th>" . $row["watchkeeping"] . "</th>";
                echo "<th>" . $row["active"] . "</th>";
                //echo "<td><form action=\"editcrew.php\" method=\"post\"><a href='editcrew.php?del={$row['crew_id']}'>edit</a></form></td>";
                echo "<td><a href=\"editcrew.php?id=" . $row['crew_id'] . "\">Edit</a>";
               echo "<td><form action=\"delete.php\" method=\"post\"><a href='crewlisting.php?del={$row['crew_id']}'>delete</a></form></td>";
            }
            ?>

You are closing your mysqli connection in the first iteration of your loop. Move the mysqli_close($con); behind the loop.

Edit: And you also redirect to crewlist.php in the loop. If you reformat your indentation of your code, this will get obvious.

Remove mysqli_close($con) from loop:

while ($row = mysqli_fetch_array($result)) {
    $sqlQueryStr = "UPDATE crewlist SET crew_name = '$CrewName', crew_rank = '$CrewRank', start_date = '$StartDate' "
            . ", end_date = '$EndDate', payroll_no = '$PayrollNo'"
            . ", employee_no = '$EmployeeNo', watchkeeping = '$WatchKeeping', active = '$Active' WHERE crew_id = " . $row['crew_id'];

    mysqli_query($con, $sqlQueryStr);

}
header('Location: crewlisting.php');