How to edit a row in mysql using php. I have a table , i will fetch it into php page to display the table in html format and at the end i have a edit button when i click edit button then the row should be editable and i can enter new values and that should update in the same table row.. after c licking edit button the button should change to submit/update...
you can use this simple method:
HTML for each EDIT link add the id
of the row:
<a href="edit.php?id=4">EDIT</a>
edit.php :
if(isset($_GET["id"])){
echo "start editing the row that have id".$id;
}
This is one of the basic actions, which falls into the category of CRUD functions. Here are the few steps you need to know to get you started.
id
, to the edit link of each page. id
and fetch the record from the database id
in most probably a hidden element. UPDATE
query based on the data and execute them. The Jquery Editable Data Tables plugin could be the best solution you need. See code google for documentation and implementation here: http://code.google.com/p/jquery-datatables-editable/
Note: Doing basic CRUP is completely time-consuming, both in the back-end and front-end, and other people usually solved this predicament a long time ago, you just need to HUG their solutions, and customize them to your liking.
But always when you asked help of other tell what you have tried..
This is just rough graph:-
$data = $_REQUEST;
if((isset($data['user_ids'])) && (count($data['user_ids']) == 1)){
$id =$data['user_ids'][0];
$sql= "UPDATE no_service SET `Status` = '$data[status_select_update]' WHERE id = $id ";
}elseif ((isset($data['user_ids'])) && (count($data['user_ids']) > 1)) {
$ids = implode(",",$data['user_ids']);
$sql= "UPDATE no_service SET `Status` = '$data[status_select_update]' WHERE id IN($ids)";
}else{
}
Edit is totally based on your id.. what you are passing.. Based on that id it will updated your records in Mysql..
I hope it will help..
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.