如何根据从 html

发布于 2024-12-02 22:07:27 字数 777 浏览 0 评论 0原文

我在 mysql 数据库中有一个表,如下所示:

id     usr   request   type    status    
1     name1   msg 1   leave    Pending     
2     name2   msg 2    sick    Pending    
3     name3   msg 3   leave    Pending 

我有两个 php 文件,即 addrequest.php 和 informrequest.php ...顾名思义,一个允许用户添加请假等请求,另一个将被使用同意或否认同样的事情。当用户创建请求时,它会被添加到 mysql 数据库,状态为“待处理”。默认情况下添加“待处理”状态。 创建请求后,它在confirmrequest.php中变得可见,唯一的区别是后者中的状态列将包含一个带有3个选项的select标签,即,

<select name="status" >
<option value="1"><? echo "$status"; ?></option>
<option value="1">Approved</option>
<option value="2">Dis-approved</option>

一旦批准者选择标签在confirmrequest.php中批准或拒绝相同的内容,它应该在mysql数据库中更新。只有请求已被确认或拒绝的记录才应在为其创建请求的数据库中进行更新。我该怎么办?

I have a table in mysql db as shown:

id     usr   request   type    status    
1     name1   msg 1   leave    Pending     
2     name2   msg 2    sick    Pending    
3     name3   msg 3   leave    Pending 

I have two php files, namely addrequest.php and confirmrequest.php... As the name suggests, one allows the user to add a request for leave etc. and the other would be used to approve or deny the same. When a user creates a request, it gets added to the mysql db with the status 'Pending'. The 'Pending' status is added by default.
Once the request is created, it becomes visible in the confirmrequest.php, only difference being that the status column in the latter would consist of a select tag with 3 options namely,

<select name="status" >
<option value="1"><? echo "$status"; ?></option>
<option value="1">Approved</option>
<option value="2">Dis-approved</option>

Once the approver selects the tag to approve or deny the same in confirmrequest.php, it should get updated in the mysql db. Only the record for which the request has been confirmed or denied should get updated in the db for which the request was created. How should i go about this???

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

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

发布评论

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

评论(1

喵星人汪星人 2024-12-09 22:07:27

将选择的项目放入表单中,在其中插入包含 request_id 的隐藏文本字段。
当用户发布表单(例如使用接受按钮)时,您会读取 $_GET['request_id']$_GET['status'] 并创建正确的更新查询。
始终清理用户输入!!

Put select items in a form in which you insert a hidden text field containing request_id.
When user posts form (with an accept button for example) you read $_GET['request_id'] and $_GET['status'] and create the correct update query.
Be careful to always sanitize user input!!

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