开发者

How to update a mysql query based on the option selected from html <select> tag

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,

开发者_如何学C<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???


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!!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜