ช่วยด้วยครับ พอดีผมเป็นมือใหม่ จะแก้ไขคำสั่ง button ยังไงดี


จากรูปคือ ผมเลือกบรรทัดที่ 2 แต่ข้อมูลโชว์แค่บรรทัดที่ 1. *หากใช้คำสั่ง <a href="form_emp_edit.php?emp_id=<ช?php echo $row['emp_id']; ?>">edit</a> จะมาครบ* แต่ใช้คำสั่ง button มันดันโชว์แค่บรรทัดที่ 1 เวลา Update ข้อมูลไป มันก็จะไปแค่บรรทัด 1
**โค้ด form ที่ผมใช้**
<?php
session_start();
include_once ('../db_connect.php');
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>พนักงาน</title>
    <!-- ======= Styles ====== -->
    <link rel="stylesheet" href="../assets/css/style.css">
    <link rel="stylesheet" href="../assets/css/sb-admin-2.min.css">
    <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Google Sans">
    <script src='https://kit.fontawesome.com/a076d05399.js' crossorigin='anonymous'></script>
</head>
<body>
    <!-- ============= Navigation =========== -->
    <div class="">
        <div class="navigation">
            <?php include ("../inc/nav.php"); ?>
        </div>
    </div>
    <!-- =============== Main ========= -->
    <div class="main">
        <?php include ("../inc/nav2.php"); ?>
        <!-- =================================== Modal form add Start =============================== -->
        <?php include 'form_emp_add.php'; ?>
        <!-- ==================================== Modal form add End ==================================-->
        <!-- ==================================== Modal form edit Start ================================-->
        <?php include 'form_emp_edit.php' ?>
        <!-- ================================ Modal form edit End ====================================-->
        <div class="card shadow mb-4">
            <div class="card-header py-3">
                <h4 class="m-2 font-weight-bold text-primary">Employee
                    <button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#insertdata">
                        New
                    </button>
            </div>
            <div class="card-body">
                <div class="table-responsive">
                    <div id="dataTable_wrapper" class="dataTables_wrapper dt-bootstrap4 no-footer">
                        <div class="row">
                            <div class="col-sm-12 col-md-6">
                                <div class="dataTables_length" id="dataTable_length"><label>Show <select
                                            name="dataTable_length" aria-controls="dataTable"
                                            class="custom-select custom-select-sm form-control form-control-sm">
                                            <option value="10">10</option>
                                            <option value="25">25</option>
                                            <option value="50">50</option>
                                            <option value="100">100</option>
                                        </select> entries</label></div>
                            </div>
                            <div class="col-sm-12 col-md-6">
                                <div id="dataTable_filter" class="dataTables_filter"><label>Search:<input type="search"
                                            class="form-control form-control-sm" placeholder=""
                                            aria-controls="dataTable"></label></div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-sm-12">
                                <table class="table table-bordered dataTable no-footer" id="dataTable" width="100%"
                                    cellspacing="0" role="grid" aria-describedby="dataTable_info" style="width: 100%;">
                                    <thead>
                                        <tr role="row">
                                            <th class="sorting" tabindex="0" aria-controls="dataTable" rowspan="1"
                                                colspan="1" aria-label="Role: activate to sort column ascending"
                                                style="width: 10%;">ID</th>
                                            <th class="sorting_asc" tabindex="0" aria-controls="dataTable" rowspan="1"
                                                colspan="1" aria-sort="ascending"
                                                aria-label="First Name: activate to sort column descending"
                                                style="width: 15%;">
                                                First Name</th>
                                            <th class="sorting" tabindex="0" aria-controls="dataTable" rowspan="1"
                                                colspan="1" aria-label="Last Name: activate to sort column ascending"
                                                style="width: 15%;">
                                                Last Name</th>
                                            <th class="sorting" tabindex="0" aria-controls="dataTable" rowspan="1"
                                                colspan="1" aria-label="USER: activate to sort column ascending"
                                                style="width: 20%;">
                                                Username</th>
                                            <!-- <th class="sorting" tabindex="0" aria-controls="dataTable" rowspan="1"
                                                colspan="1" aria-label="Role: activate to sort column ascending"
                                                style="width: 57.2px;">Password</th> -->
                                            <!-- <th class="sorting" tabindex="0" aria-controls="dataTable" rowspan="1"
                                                colspan="1" aria-label="Role: activate to sort column ascending"
                                                style="width: 15%;">Department</th> -->
                                            <th class="sorting" tabindex="0" aria-controls="dataTable" rowspan="1"
                                                colspan="1" aria-label="Role: activate to sort column ascending"
                                                style="width: 20%;">Date
                                            </th>
                                            <th class="sorting" tabindex="0" aria-controls="dataTable" rowspan="1"
                                                colspan="1" aria-label="Action: activate to sort column ascending"
                                                style="width: 20%;">
                                                Action</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <?php include '../db_connect.php';
                                        $query = "SELECT * FROM employees";
                                        $result = mysqli_query($conn, $query) or die("Error in sql ;$query" . mysqli_error($conn));
                                        ?>
                                        <?php foreach ($result as $row) { ?>
                                            <tr>
                                                <td>
                                                    <?php echo $row['emp_id']; ?>
                                                </td>
                                                <td>
                                                    <?php echo $row['emp_name']; ?>
                                                </td>
                                                <td>
                                                    <?php echo $row['emp_last']; ?>
                                                </td>
                                                <td>
                                                    <?php echo $row['emp_user']; ?>
                                                </td>
                                                <td>
                                                    <?php echo $row['emp_date']; ?>
                                                </td>
                                                <td>
                                                    <!-- <a href="form_emp_edit.php?emp_id=<ช?php echo $row['emp_id']; ?>">edit</a> -->
                                                    <!-- <li>
                                                        <a type="button"
                                                            class="btn btn-primary"
                                                            style="border-radius: 0px;"
                                                            href="emp_edit.php?action=edit & id=' . $row['EMPLOYEE_ID'] . '">
                                                            <i class="fas fa-fw fa-edit"></i> Edit
                                                        </a>
                                                    </li> -->
                                                    <button type="submit" class="btn btn-primary" data-bs-toggle="modal"data-bs-target="#editEmployeeModal"<?php echo $row['emp_id']; ?> >Edit</button>
                                                </td>
                                            </tr>
                                        <?php } ?>
                                    </tbody>
                                </table>
                                <?php mysqli_close($conn); ?>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!-- =========== Scripts =========  -->
    <?php include ("../inc/navscript.php"); ?>
</body>
</html>
แสดงความคิดเห็น
โปรดศึกษาและยอมรับนโยบายข้อมูลส่วนบุคคลก่อนเริ่มใช้งาน อ่านเพิ่มเติมได้ที่นี่