PHP 编辑表中的唯一行

发布于 2024-08-28 07:00:38 字数 332 浏览 4 评论 0 原文

我目前有一个 PHP 表单,它使用 AJAX 连接到 MySQL 并显示与用户选择匹配的记录 (AJAX:显示带有多个选择框值的 MySQL 数据

除了显示数据之外,我还在每个结果旁边放置了一个“编辑”按钮,该按钮显示一个表单,其中数据可以编辑。我的问题是编辑唯一记录,因为目前我仅使用“姓名”和“年龄”的选定值来查找记录。如果两个(或更多)记录具有相同的姓名和年龄,我只能编辑第一个结果。

I currently have a PHP form that uses AJAX to connect to MySQL and display records matching a user's selection (AJAX: Display MySQL data with value from multiple select boxes)

As well as displaying the data, I also place an 'Edit' button next to each result which displays a form where the data can be edited. My problem is editing unique records since currently I only use the selected values for 'name' and 'age' to find the record. If two (or more) records share the same name and age, I am only able to edit the first result.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

违心° 2024-09-04 07:00:38

假设您的编辑文件是 edit.php。然后,在生成编辑链接的文件中,尝试更改编辑按钮链接,如下所示:

'编辑'

然后你将能够访问 ID 变量

echo $_REQUEST['ID'];

请注意,ID 区分大小写。让我知道进展如何。

Let's assume your file for editing is edit.php. Then, in the file where you generate the edit links, try changing your edit button link as follows:

'<a href="edit.php?id="'.$row['ID'].'">edit</a>'

Then you will be able to access ID variable as

echo $_REQUEST['ID'];

Note that the ID is case sensitive. Let me know how it goes.

执着的年纪 2024-09-04 07:00:38

当显示来自ajax的记录时,还发送主字段(大多数情况下为id)以及姓名和年龄

,当您显示这些数据并进行编辑时,将主字段与编辑合并起来

when displaying records from ajax, also send the primary field(id in most cases) along with name and age

and when u are displaying these data along with edit incorporate that primary field with edit

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文