How to pass the data database to view using script and php? - javascript

I have getpunch method in script and PHP also what i want is pass the hours:minuts between in_time and current time
This is my script :
AttendanceAdapter.method('getPunch', function(successCallBack) {
var that = this;
var object = {};
object['date'] = this.getClientDate(new Date()).toISOString().slice(0, 19).replace('T', ' ');
object['offset'] = this.getClientGMTOffset();
var reqJson = JSON.stringify(object);
var callBackData = [];
callBackData['callBackData'] = [];
callBackData['callBackSuccess'] = successCallBack;
callBackData['callBackFail'] = 'getPunchFailCallBack';
this.customAction('getPunch','modules=attendance',reqJson,callBackData);
});
This is my PHP :
public function getPunch($req){
$date = $req->date;
$arr = explode(" ",$date);
$date = $arr[0];
$employee = $this->baseService->getElement('Employee',$this->getCurrentEmployeeId(),null,true);
//Find any open punch
$attendance = new Attendance();
$attendance->Load("employee = ? and DATE_FORMAT( in_time, '%Y-%m-%d' ) = ? and (out_time is NULL or out_time = '0000-00-00 00:00:00')",array($employee->id,$date));
if($attendance->employee == $employee->id){
//found an open punch
return new IceResponse(IceResponse::SUCCESS,$attendance);
}else{
return new IceResponse(IceResponse::SUCCESS,null);
}}
using this when user try to punch_out in that form showing in_time i want show in that form how many hours they worked when they try to punch_out

Related

How add a filter in server script with query

i'm new in servicenow and I have to add this filter "document_id.number STARTS WITH BKNG"
as a query, how can i do in servicenow?
this is my code:
// only show 30 in header menu dropdown
var max = 30;
var t = data;
t.items = [];
t.count = 0;
var u = getMyApprovals();
// use record watchers to tell header when to update dropdown counts
t.record_watchers = [];
t.record_watchers.push({'table':'sysapproval_approver','filter':'approverIN' + u.toString() + '^state=requested'});
var z = new GlideRecord('sysapproval_approver');
z.addQuery("approver", u);
z.addQuery("state", "requested");
z.addQuery("document_id.number", "STARTSWITH", "BKNG")
z.orderByDesc('sys_updated_on');
z.setLimit(max);
z.query();
var link = {};
link.title = gs.getMessage('View all approvals');
link.type = 'link';
link.href = '?id=approvals';
link.items = [];
t.items.push(link);
while (z.next()) {
var a = {};
var rec = getRecordBeingApproved(z);
if (!rec.isValidRecord()) // nothing being approved - hmmm
continue;
a.short_description = rec.short_description + "";
if (rec.getRecordClassName() == "sc_request") {
var items = new GlideRecord("sc_req_item");
items.addQuery("request", rec.getUniqueValue());
items.query();
if (items.getRowCount() > 1)
a.short_description = items.getRowCount() + " requested items";
else if (items.getRowCount() == 1) {
items.next();
a.short_description = items.getValue("short_description");
}
}
$sp.getRecordValues(a, z, 'sys_id,sys_updated_on');
a.number = rec.getDisplayValue();
a.__table = z.getRecordClassName();
a.type = 'approval';
t.items.push(a);
t.count++;
}
function getRecordBeingApproved(gr) {
if (!gr.sysapproval.nil())
return gr.sysapproval.getRefRecord();
return gr.document_id.getRefRecord();
}
i tried doing z.addQuery ("document_id.number", "STARTSWITH", "BKNG")
but it doesn't works.
i don't know how to do.
You can't dot-walk the document_id field when using .addQuery() as it is not a reference filed. Instead, you can use the Approval for (sysapproval) reference field like so:
z.addQuery("sysapproval.number", "STARTSWITH", "BKNG");

Data Formate almost done, But does not show candlestick chart

Frist send data view page than json_encoded array data by Laravel. json_encode after var livetrde = '';
livetrdeObj = jQuery.parseJSON(livetrde);
Data formate almost done. I can't understand why does not show my chart data.
enter image description here
`for($i=0; $i<$different_days; $i=$i+$day){
$data[$i] = TradingProduct::where('group_product_id', $group_product_id)
->whereBetween(TradingProduct::raw('date(created_at)'), [Carbon::now()->subDays($i+$day), Carbon::now()->subDays($i)])
->orderBy('created_at', 'ASC')
->get();
$liveTrade = [];
$arrData = [];
foreach ($data as $key => $value) {
$arrData[$key] = $value;
$open = [];
$high = [];
$low = [];
$close = [];
$arrPrice = [];
$time = [];
$dd = 15;
$j = 0;
foreach ($arrData[$key] as $arrDatakey => $arr) {
if(!empty($arr['price'])){
$arrPrice[$arrDatakey] = $arr['price'];
$time[] = $arr['created_at'];
$open = reset($arrPrice);
$high = max($arrPrice);
$low = min($arrPrice);
$close = last($arrPrice);
$start_date_time = Carbon::now()->subDays($j);
$end_date_time = Carbon::now()->subDays($j+$dd);
$different_days_time = $start_date_time->diffInDays($end_date_time);
$currentTime = $start_date_time->subDays($different_days_time)->timestamp;
$j = $j+$dd;
}
}
$liveTrade[] = '{x: new Date('.$currentTime.'), y: ['.$open.','.$high.','.$low.','.$close.']}';
}
}`
The problem is here in creating the $liveTrade[] data. You are using Date() as string where it should create an object (Note that I'm already formatting the date in php itself in the format 'Y-m-d' which can be changed as per your needs). Update it to be like this:
$liveTrade[] = '{x: ' . (date('c', $currentTime)) .', y: ['.$open.','.$high.','.$low.','.$close.']}';
The better solution would be to push and array into $liveTrade[] and later in the end convert it into json like below:
// within the foreach loop you need to convert timestamp to date
$liveTrade[] = array('x' => date('c', $currentTime), 'y' => [$open, $high, $low, $close]);
// use date('D M d Y H:i:s O', $currentTime) to mimic JS date object
// ... Before returning response
$response = json_encode($liveTrade);
echo $response;

How to set a time-driven (clock) trigger for a function that needs parameters sent to it?

I'm trying to have a function run with a time-driven (clock) trigger. My issue is, the function needs variables sent to it as parameters. Normally if I'm not using a trigger I'll just send it directly like this.
<script>
function runFunction(){
google.script.run.myFunction(x,y,z);
}
</script>
And on the server side, I'll call them easily.
function myFunction(x,y,z){
var a = x;
var b = y;
var c = z;
Logger.log(a+b+c);
}
But when I'm using a time-driven (clock) trigger to run the function how can I get x,y,z into the function.
I searched around and saw one method of creating scriptProperties out of the parameters in the trigger function like this.
EDITED This is the actual code.
Client side.
<script>
function sendCall() {
var testNumber = document.getElementById('numberCall').value;
var testGroup = document.getElementById('groupsCall').value;
var testtime = document.getElementById('scheduleCall').value;
var now = document.getElementsByName('sendTimeCall')[0].checked;
var number;
if(testNumber == ''){
number = null;
}else{
number = testNumber;
}
var group;
if(testGroup == ""){
group = null;
}else{
group = testGroup;
}
var time;
if(testtime == ''){
time = null;
}else{
time = testtime;
}
var file = document.getElementsByName('audio')[0].files[0];
var name = file.name;
var reader = new FileReader();
reader.onload = function (e) {
var content = reader.result;
google.script.run.withSuccessHandler(success2).triggerCall(group, number, content, time, now, name);
return false;
}
reader.readAsDataURL(file);
}
</script>
Server side - Trigger Function.
function triggerCall(group, number, content, time, now, name){
var scriptProperties = PropertiesService.getScriptProperties();
scriptProperties.setProperties({
'GROUP_CALL': group,
'AUDIO': content,
'NUMBER_CALL': number,
'FILE_NAME': name
});
var status;
if(now){
status = 'Call Sent';
}else{
status = 'Call Scheduled';
}
if(now){
return makeCall(status);
}else{
// Set here the date you want to schedule the one-time trigger
var rawdate = time;
var today_D = new Date(new Date().toLocaleString("en-US", {timeZone: "America/New_York"}));
var scheduled_D = new Date(rawdate);
var time_af = Math.abs(scheduled_D - today_D) / 36e5;
ScriptApp.newTrigger("makeCall")
.timeBased()
.after(time_af * 60 *60 * 1000)
.create();
}
return status;
}
Server side - Here is The function that actually does the work.
function makeCall(status) {
var scriptProperties = PropertiesService.getScriptProperties();
var blob = scriptProperties.getProperty('AUDIO');
var number = scriptProperties.getProperty('NUMBER_CALL');
var group = scriptProperties.getProperty('GROUP_CALL');
var name = scriptProperties.getProperty('FILE_NAME');
var fullNumber;
if(group){
var ss = SpreadsheetApp.openById('xxxxxxxxxxxxxxxxxxx');
var sheet = ss.getSheetByName(group)
var length = sheet.getLastRow();
var values = sheet.getRange(1, 1, length).getValues();
fullNumber = values.flat();
}else{
var num = number;
var prefix = '+1';
var removeDashes = num.replace(/-/g,"");
var format = prefix + removeDashes;
var comma = format.replace(/ /g, ' +1');
fullNumber = comma.split(' ')
}
//upload file to drive
var folder = DriveApp.getFolderById('xxxxxxxxxxxxxxxxxxxxxx');
var blob = blob.split(",");
var blob = Utilities.newBlob(Utilities.base64Decode(blob[1]), 'audio/mpeg', name);
var file = folder.createFile(blob);
file.setSharing(DriveApp.Access.ANYONE_WITH_LINK, DriveApp.Permission.VIEW);
var id = file.getId();
for (var i = 0; i < fullNumber.length; i++){
//the url with HTTP request to create a call and parameters
var callsUrl = "https://api.twilio.com/2010-04-01/Accounts/ACxxxxxxxxxxxxxxxx/Calls.json";
var payload = {
"To": fullNumber[i],
"From" : "+177777777",
"Twiml" : "<Response><Play>https://docs.google.com/uc?export=play&id=" + id + "</Play></Response>",
};
var options = {
"method" : "post",
"payload" : payload
};
options.headers = {
"Authorization" : "Basic " + Utilities.base64Encode("xxxxxxxxxxx:xxxxxxxx")
};
UrlFetchApp.fetch(callsUrl, options);
}
scriptProperties.deleteProperty('AUDIO');
scriptProperties.deleteProperty('NUMBER_CALL');
scriptProperties.deleteProperty('GROUP_CALL');
scriptProperties.deleteProperty('FILE_NAME');
return status;
}
The problem is when I run the above code without the file input it works, But when I run it as above the function doesn't work. I did some trouble shooting and I think it has to do with transferring the file as a Data URL via the properties method. Is there a limit to how long of a string the VALUE can be?
in a nut shell these are the 2 points of my question.
Any other ideas how to send parameters to a triggered function
How I could do it using PropertiesService.
I would like to propose the following modification.
Modification points:
I think that the reason of your issue might be due to the maximum data size for PropertiesService. In the current stage, it seems that "Properties total storage" is "500kB / property store". I thought that in this case, when you upload a file, the file size might be over than it.
In order to remove your issue, how about creating content as a temporal file and put the file ID to the PropertiesService?
When above points are reflected to your script, it becomes as follows.
Pattern 1:
In this pattern, content is saved as a temporal file and that is used in the function of makeCall().
triggerCall()
function triggerCall(group, number, content, time, now, name){
var scriptProperties = PropertiesService.getScriptProperties();
var tempFile = DriveApp.createFile("tempFile.txt", content, MimeType.PLAIN_TEXT); // Added
scriptProperties.setProperties({'GROUP_CALL': group,'AUDIO': tempFile.getId(),'NUMBER_CALL': number,'FILE_NAME': name}); // Modified
var status;
if(now){
status = 'Call Sent';
}else{
status = 'Call Scheduled';
}
if(now){
return makeCall(status);
}else{
var rawdate = time;
var today_D = new Date(new Date().toLocaleString("en-US", {timeZone: "America/New_York"}));
var scheduled_D = new Date(rawdate);
var time_af = Math.abs(scheduled_D - today_D) / 36e5;
ScriptApp.newTrigger("makeCall").timeBased().after(time_af * 60 *60 * 1000).create();
}
return status;
}
makeCall()
function makeCall(status) {
var scriptProperties = PropertiesService.getScriptProperties();
var tempfileId = scriptProperties.getProperty('AUDIO'); // Modified
var number = scriptProperties.getProperty('NUMBER_CALL');
var group = scriptProperties.getProperty('GROUP_CALL');
var name = scriptProperties.getProperty('FILE_NAME');
var fullNumber;
if(group){
var ss = SpreadsheetApp.openById('xxxxxxxxxxxxxxxxxxx');
var sheet = ss.getSheetByName(group)
var length = sheet.getLastRow();
var values = sheet.getRange(1, 1, length).getValues();
fullNumber = values.flat();
}else{
var num = number;
var prefix = '+1';
var removeDashes = num.replace(/-/g,"");
var format = prefix + removeDashes;
var comma = format.replace(/ /g, ' +1');
fullNumber = comma.split(' ')
}
var folder = DriveApp.getFolderById('xxxxxxxxxxxxxxxxxxxxxx');
var tempFile = DriveApp.getFileById(tempfileId); // Added
var text = tempFile.getBlob().getDataAsString(); // Added
tempFile.setTrashed(true); // Added
var blob = text.split(","); // Modified
var blob = Utilities.newBlob(Utilities.base64Decode(blob[1]), 'audio/mpeg', name);
var file = folder.createFile(blob);
file.setSharing(DriveApp.Access.ANYONE_WITH_LINK, DriveApp.Permission.VIEW);
var id = file.getId();
for (var i = 0; i < fullNumber.length; i++){
var callsUrl = "https://api.twilio.com/2010-04-01/Accounts/ACxxxxxxxxxxxxxxxx/Calls.json";
var payload = {"To": fullNumber[i],"From" : "+177777777","Twiml" : "<Response><Play>https://docs.google.com/uc?export=play&id=" + id + "</Play></Response>"};
var options = {"method" : "post","payload" : payload};
options.headers = {"Authorization" : "Basic " + Utilities.base64Encode("xxxxxxxxxxx:xxxxxxxx")};
UrlFetchApp.fetch(callsUrl, options);
}
scriptProperties.deleteProperty('AUDIO');
scriptProperties.deleteProperty('NUMBER_CALL');
scriptProperties.deleteProperty('GROUP_CALL');
scriptProperties.deleteProperty('FILE_NAME');
return status;
}
Pattern 2:
In this pattern, content is saved to a file as the decoded data and that is used in the function of makeCall().
triggerCall()
function triggerCall(group, number, content, time, now, name){
var scriptProperties = PropertiesService.getScriptProperties();
var folder = DriveApp.getFolderById('xxxxxxxxxxxxxxxxxxxxxx'); // Added
var blob = content.split(","); // Added
var blob = Utilities.newBlob(Utilities.base64Decode(blob[1]), 'audio/mpeg', name); // Added
var file = folder.createFile(blob); // Added
scriptProperties.setProperties({'GROUP_CALL': group,'AUDIO': file.getId(),'NUMBER_CALL': number,'FILE_NAME': name}); // Modified
var status;
if(now){
status = 'Call Sent';
}else{
status = 'Call Scheduled';
}
if(now){
return makeCall(status);
}else{
var rawdate = time;
var today_D = new Date(new Date().toLocaleString("en-US", {timeZone: "America/New_York"}));
var scheduled_D = new Date(rawdate);
var time_af = Math.abs(scheduled_D - today_D) / 36e5;
ScriptApp.newTrigger("makeCall").timeBased().after(time_af * 60 *60 * 1000).create();
}
return status;
}
makeCall()
function makeCall(status) {
var scriptProperties = PropertiesService.getScriptProperties();
var fileId = scriptProperties.getProperty('AUDIO'); // Modified
var number = scriptProperties.getProperty('NUMBER_CALL');
var group = scriptProperties.getProperty('GROUP_CALL');
var name = scriptProperties.getProperty('FILE_NAME');
var fullNumber;
if(group){
var ss = SpreadsheetApp.openById('xxxxxxxxxxxxxxxxxxx');
var sheet = ss.getSheetByName(group)
var length = sheet.getLastRow();
var values = sheet.getRange(1, 1, length).getValues();
fullNumber = values.flat();
}else{
var num = number;
var prefix = '+1';
var removeDashes = num.replace(/-/g,"");
var format = prefix + removeDashes;
var comma = format.replace(/ /g, ' +1');
fullNumber = comma.split(' ')
}
var file = DriveApp.getFileById(fileId); // Modified
file.setSharing(DriveApp.Access.ANYONE_WITH_LINK, DriveApp.Permission.VIEW);
var id = file.getId();
for (var i = 0; i < fullNumber.length; i++){
var callsUrl = "https://api.twilio.com/2010-04-01/Accounts/ACxxxxxxxxxxxxxxxx/Calls.json";
var payload = {"To": fullNumber[i],"From" : "+177777777","Twiml" : "<Response><Play>https://docs.google.com/uc?export=play&id=" + id + "</Play></Response>"};
var options = {"method" : "post","payload" : payload};
options.headers = {"Authorization" : "Basic " + Utilities.base64Encode("xxxxxxxxxxx:xxxxxxxx")};
UrlFetchApp.fetch(callsUrl, options);
}
scriptProperties.deleteProperty('AUDIO');
scriptProperties.deleteProperty('NUMBER_CALL');
scriptProperties.deleteProperty('GROUP_CALL');
scriptProperties.deleteProperty('FILE_NAME');
return status;
}
Note:
In this modified script, when a file is uploaded, content is saved as a temporal file and the file ID is put to the PropertiesService. When makeCall is run, content is retrieved by the file ID and convert to the blob and saved it as a file. And the temporal file is removed. By this, the limitation of PropertiesService can be cleared.
But, in the current stage, the maximum blob size of Google Apps Script is 50 MB (52,428,800 bytes). So when the uploaded file size is over 50 MB, an error occurs. In this case, the file is converted to the base64 data. So, the maximum size is the size of base64 data. Please be careful this.
Reference:
Current limitations

Trying to send a javascript array of objects to my other php file where I can decode it and save the elements to my database

Hi I have searched everywhere and although some questions and answers have helped I still cannot seem to get my array of objects to send to my PHP file (body_parts_submit.php).
Basically, I have created 6 arrays and within them they have objects its complicated but I want every body part, every exercise every set and rep and weight value to be different so I can distinguish between them later on.
The success function never seems to run when I run the code in a browser, so it could be the way I've structured the arrays or the javascript itself. Any help would be much appreciated I've been sitting on this problem for days.
$("#add-cart").click(function(){
var numBodyParts = parseInt($("input[name='number_bodypart']").val());
var bodyParts = new Array();
bodyParts[0] = "Body Parts:";
var exerciseNames = new Array();
exerciseNames[0] = new Array();
exerciseNames[0][0] = "Exercise names:";
var numOfSets = new Array();
numOfSets[0] = new Array();
numOfSets[0][0] = "Number of sets per exercise:";
var setNum = new Array();
setNum[0] = new Array();
setNum[0][0] = new Array();
setNum[0][0][0] = "Set Number:";
var repValue = new Array();
repValue[0] = new Array();
repValue[0][0] = new Array();
repValue[0][0][0] = "Number of reps:";
var weightValue = new Array();
weightValue[0] = new Array();
weightValue[0][0] = new Array();
weightValue[0][0][0] = "Amount of weight:";
for(b=1;b<=numBodyParts;b++){
bodyParts[b] = {bodypart:document.getElementById("bodypart_select"+b).value};
var numExercises = document.getElementById("table"+b).rows.length;
exerciseNames[b] = new Array();
numOfSets[b] = new Array();
setNum[b] = new Array();
repValue[b] = new Array();
weightValue[b] = new Array();
for(e = 1; e<=numExercises;e++){
exerciseNames[b][e] = {exercise:document.getElementById("exercise_"+b+"_"+e).value};
numOfSets[b][e] = {numofsets:document.getElementById("number_set_"+b+"_"+e).value};
var numofSets = document.getElementById("set_"+b+"_"+e).rows.length;
setNum[b][e] = new Array();
repValue[b][e] = new Array();
weightValue[b][e] = new Array();
for(s=1; s<=numofSets; s++){
setNum[b][e][s] = {setnum:s};
repValue[b][e][s] = {reps:document.getElementById(b+"_reps_"+e+"_"+s).value};
weightValue[b][e][s] = {weight:document.getElementById(b+"_weight_"+e+"_"+s).value};
}
}
}
var test1 = JSON.stringify(bodyParts[1]);
var test2 = JSON.stringify(exerciseNames);
var test3 = JSON.stringify(numOfSets);
var test4 = JSON.stringify(setNum);
var test5 = JSON.stringify(repValue[1][2][2]);
var test6 = JSON.stringify(weightValue[1][1][1]);
console.log(test1);
console.log(test2);
console.log(test3);
console.log(test4);
console.log(test5);
console.log(test6);
$.ajax({
type: "post",
url: "body_parts_submit.php",
data: {bodyparts:JSON.stringify(bodyParts[1])},
success: function(data){
alert("Success");
console.log(data);
},
error: function(e){
console.log(e.message);
},
dataType: "json"
});
});
Below is my php file - body_parts_submit.php
$data = json_decode($_POST["bodyparts"]);
if(isset($_POST["bodyparts"]))
{
$data = json_decode($_POST["bodyparts"]);
echo('{"reason": "'.$data.'"}');
}
else{
echo ('{"reason": "failure"}');
}

Edit data from table with javascript and php from ajax

I am a beginner in PHP and Javascript I used a live editable table and I am trying to edit them and then save them to mysql in another page I did like this, but I didn't know how to retrieve where to edit in mysql with the id could some one help please! Am i wrong in the request? it doesn't change in the database like it does in the table in the page. I sent the data like this:
function postedit()
{
var _type = $('#typeid').val();
var _pression = $('#pressionid').val();
var _code = $('input[name="code"]').val();
var _designiation = $('input[name="designiation"]').val();
var _diametre = $('input[name="diametre"]').val();
var _epaisseur = $('input[name="epaisseur"]').val();
var _prix = $('input[name="prix"]').val();
var _etat = $('input[name="etat"]').val();
$.post('update.php', {
posttype: _type,
postpression: _pression,
postcode: _code,
postdesigniation: _designiation,
postdiametre: _diametre,
postepaisseur: _epaisseur,
postprix:_prix,
postetat:_etat
},
function(data){
$('tbody').append(data);
});
}
var _trEdit = null;
$(document).on('click', '.btn-edit',function(){
_trEdit = $(this).closest('tr');
var _code = $(_trEdit).find('td:eq(0)').text();
var _designiation = $(_trEdit).find('td:eq(1)').text();
var _diametre = $(_trEdit).find('td:eq(2)').text();
var _epaisseur = $(_trEdit).find('td:eq(3)').text();
var _prix = $(_trEdit).find('td:eq(4)').text();
var _etat = $(_trEdit).find('td:eq(5)').text();
$('input[name="code"]').val(_code);
$('input[name="designiation"]').val(_designiation);
$('input[name="diametre"]').val(_diametre);
$('input[name="epaisseur"]').val(_epaisseur);
$('input[name="prix"]').val(_prix);
$('input[name="etat"]').val(_etat);
});
$('#btn-update').click(function(){
if(_trEdit){
var _code = $('input[name="code"]').val();
var _designiation = $('input[name="designiation"]').val();
var _diametre = $('input[name="diametre"]').val();
var _epaisseur = $('input[name="epaisseur"]').val();
var _prix = $('input[name="prix"]').val();
var _etat = $('input[name="etat"]').val();
$(_trEdit).find('td:eq(0)').text(_code);
$(_trEdit).find('td:eq(1)').text(_designiation);
$(_trEdit).find('td:eq(2)').text(_diametre);
$(_trEdit).find('td:eq(3)').text(_epaisseur);
$(_trEdit).find('td:eq(4)').text(_prix);
$(_trEdit).find('td:eq(5)').text(_etat);
alert("Ligne Modifier avec succée !");
_trEdit = null;
}
});
My sql request in a file update.php like this I thought that if I get the id from the database and search from it, it seems stupid but I am desperate:
$type_utilisation = $_POST['posttype'];
$pression_tube = $_POST['postpression'];
$code_tube = $_POST['postcode'];
$designiation_tube = $_POST['postdesigniation'];
$diametre_tube = $_POST['postdiametre'];
$epaisseur_tube = $_POST['postepaisseur'];
$prix_tube = $_POST['postprix'];
$etat_tube = $_POST['postetat'];
$id_req = ("select id from $pression_tube where typepehd='".$type_utilisation."' && code='".$code_tube."'");
$id_tube=$id_req;
echo"$id_tube";
if(isset($pression_tube)){
if($pression_tube=="pn4"){
if($type_utilisation=="pehdtelecom" && $pression_tube=="pn4" ){
echo "verifier le type du Tube S.v.p";
} else {
$sql="UPDATE pn4 SET typepehd='".$type_utilisation."',code='".$code_tube."',designiation='".$designiation_tube."',diametre='".$diametre_tube."',epaisseur='".$epaisseur_tube."',prix='".$prix_tube."',etat='".$etat_tube."' where id='".$id_tube."'";
$result = mysqli_query($link, $sql);
if($result){
} else {
echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
}
}
}
thank you, i did solve it by using the id because its unique
$id_tube = $_POST['postid'];
by adding an input to it in type hidden
and make the column invisible by
style="display;none";

Categories