如何从php和mysql中显示的记录列表中选择和处理所选记录


How to select and process the selected records from a list of displayed records in php and mysql

我有一个php/mysql应用程序,其中有一个数据库,大致包含以下字段:

  • 员工编号
  • 员工姓名
  • 加入年份
  • 位置
  • 工作简介

我可以使用SELECT语句毫无问题地显示记录。

现在,我想能够做到以下几点,这就是我需要你帮助/建议的地方:

  1. 从显示的记录列表中随机选择一些记录(使用复选框或此处建议的任何其他方法)。

  2. 在屏幕上有一个写着"已处理"的按钮。当我点击按钮时,屏幕应该会刷新,上面步骤1中选择的记录应该会移动到另一个数据库,现在只显示未选中的记录。

请告诉我你对如何做上述工作的建议。

谢谢TS

为此,您可以使用记录的id,使用另一个单选查询来获取特定记录的信息,还可以使用记录id更新记录。(创建一个编辑链接并传递id,在编辑页面上获取带有id的信息并保存。)

<?php //your db connection and select query here ?>
<form action="process.php" method="post" enctype="multipart/form-data">
<?php
    // loop starts here
   echo "<input type='checkbox' name='ids[]' value='".$row["id"]."' />";
    // loop ends here
?>
  <input type="submit" name="process" value="Processed"/>
</form>
This will create the checkboxes and on the process.php page
you can get the ids your need to process and can move your data
to other table/db where you want and after than redirect back to
to the page where your code is.