需要在单击approve按钮后将特定行存储到数据库中

ezykj2lf  于 2021-06-17  发布在  Mysql
关注(0)|答案(0)|浏览(176)

因此,关于我的困境,我已经对我的网站进行了编码,将重新安排的课程列表返回到一个表中,供管理员批准或不批准。从数据库中检索重新安排的类的列表。
我想知道的是,当单击approve按钮时,代码将把特定行的数据存储到数据库中(假设我只想批准第一行的数据)。我该怎么做?如果可能的话,我想用它的主键来做这件事,但据我所知,主键并不稳定,例如,如果从列表中删除一个条目,键将不会被替换,而是继续自动递增。
以下是我的表格代码:

<div class="dashboard-content__panel " data-panel-id="class_replacement">
    <div class="dashboard-list report-content">
       <div id="report" class="panel panel-primary panel-table table-responsive reportTable" style="border:none; ">
         <div class="panel-body " >
           <table id="report-table" class="table table-hover"  width="100%" >
             <thead>
               <tr>
                 <th>Subject Code</th>
                 <th>Subject Rescheduling Date and Subject Start Time</th>
                 <th>Duration (hours)</th>
                 <th>Status</th>
                 <th>Select Venue</th>
                 <th>Approve/Disapprove</th>

               </tr>
             </thead>
             <tbody>
               <?php
               $conn = mysqli_connect("localhost", "root", "", "fyp1web");
               if ($conn -> connect_error) {
                 die("Connection Failed: ". $conn-> connect_error);
               }

               $sql = "SELECT * from class_rescheduling";
               $result = $conn-> query($sql);

               while ($rs = $result-> fetch_assoc()) {
               ?>
               <tr>
               <td><?php echo $rs["newSubjectID"]; ?></td>
               <td><?php echo $rs["newDateTime"]; ?></td>
               <td><?php echo $rs["newDuration"]; ?></td>
               <td><?php echo $rs["newStatus"]; ?></td>
               <td> <select name="classname">
               <?php
               $sql2 = "SELECT className FROM class_rooms";
               $result2 = $conn-> query($sql2);
               while ($rs1 = mysqli_fetch_array($result2)) {
               ?>
               <option value="<?php echo $rs1['className']; ?>"><?php echo $rs1["className"]; ?></option>
               <?php
               }
               ?>
               </select></td>
               <td><button class='btn' type='submit' name='approve'>Approve</button><button class='btn' type='submit' name='disapprove'>Disapprove</button></td>
               </tr>
             <?php
             }
             ?>
             </tbody>
                 <tfoot>
                 </tfoot>
          </table>
        </div>
      </div>
   </div>
  </div>

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题