|
 |
|
สอบถามเรื่องการส่งค่าจากการกดปุ่มไป ajax และให้ ajax ส่งค่าไปอัพเดทใน mysql |
|
 |
|
|
 |
 |
|
สอบถามเรื่องการส่งค่าจากการกดปุ่มไป ajax และให้ ajax ส่งค่าไปอัพเดทใน mysql หน่อยครับ
Code (PHP)
echo " <td id='row".$i."Col3' name='row".$i."Col3'>";
$btnLabel = ($rows[$i]["Approve"]='0' || $rows[$i]["Approve"]>0) ? "$update" : "$buttonsubmit";
echo " <button id='buttonRow".$i."' name='buttonRow".$i."' type='button' onclick='checkclick(".$rows[$i]["UID"].",selectvalueRow".$i."Col1,".$rows[$i]["CreateDate"].",checkclickRow".$i.")' class='btn btn-primary waves-effect' style='width:70px; height:24px'>".$btnLabel."</button>";
Code (PHP)
function checkclick(UID, Approve, CreateDate, checkclickID) {
$.ajax({
type: "POST",
url: "ajax-update.php",
data: { UID: UID , Approve: Approve, CreateDate: CreateDate},
async: false,
success: function(data){
if(data==true){
$('#'+checkclickID).html('<?php echo $update ?>');
}else{
alert("An error occurred");
}
},
error: function(){
alert("An error occurred");
}
});
};
Code (PHP)
list($day, $month, $year) = explode("/", $_POST["CreateDate"]);
$filterDate2 = "".$year."/".$month."/".$day."";
$conn = PDOConnector();
$comm = "UPDATE transection SET ";
$comm .= "Approve = :Approve ";
$comm .= "WHERE UID = :UID AND DATE(transection.CreateDate) =:CreateDate";
$query = $conn->prepare($comm);
$result = $query->execute(array(
"Approve" => $_POST["approve"],
"CreateDate" => $filterDate,
"UID" => $_POST["UID"]
));
Tag : PHP, MySQL, JavaScript, Ajax, XAMPP

|
ประวัติการแก้ไข 2018-04-05 14:58:47 2018-04-05 14:59:29
|
 |
 |
 |
 |
Date :
2018-04-05 14:46:13 |
By :
manman12307 |
View :
788 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (PHP)
list($day, $month, $year) = explode("/", $_POST["CreateDate"]);
$filterDate2 = "".$year."/".$month."/".$day."";
$conn = PDOConnector();
$comm = "UPDATE transection SET ";
$comm .= "Approve = :Approve ";
$comm .= "WHERE UID = :UID AND DATE(transection.CreateDate) =:CreateDate";
$query = $conn->prepare($comm);
$result = $query->execute(array(
"Approve" => $_POST["approve"],
"CreateDate" => $filterDate,
"UID" => $_POST["UID"]
));
ลองทดสอบเรียกไฟล์นี้โดยการกำหนดค่าตัวแปรดูว่ามันทำงานได้หรือไม่
Code (PHP)
$_POST["CreateDate"] = "xyz";
|
 |
 |
 |
 |
Date :
2018-04-16 13:54:01 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 02
|