<?php
//setting header to json
header('Content-Type: application/json');
require_once '../../../../init.php';
//require_once $abs_us_root.$us_url_root.'users/includes/header.php';
//echo($user->data()->id);
//echo($GLOBALS['config']['mysql']['host']);
//print json_encode($GLOBALS['config']);
//print_r(array_values($GLOBALS));
//database
define('DB_HOST', $GLOBALS['config']['mysql']['host']);
define('DB_USERNAME', $GLOBALS['config']['mysql']['username']);
define('DB_PASSWORD', $GLOBALS['config']['mysql']['password']);
define('DB_NAME', $GLOBALS['config']['mysql']['db']);
//echo($_GET['id']);
$currentuser=$user->data()->id;
if($currentuser==NULL){
$currentuser=$_GET['id'];
}
//get connection
$mysqli = new mysqli(DB_HOST, DB_USERNAME, DB_PASSWORD, DB_NAME);
$sql = 'UPDATE `session` SET `sessiondate` = \''.$_POST['sessiondate'].'\', `sessionType` = '.$_POST['sessionType'].', `note` = \''.$_POST['note'].'\', `feeling` = \''.$_POST['feeling'].'\', `extertion` = \''.$_POST['extertion'].'\', `location` = \''.$_POST['location'].'\', `tags` = \''.$_POST['tags'].'\', `pushups` = \''.$_POST['pushups'].'\', `situps` = \''.$_POST['situps'].'\', `squatkicks` = \''.$_POST['squatkicks'].'\', `rundistance` = \''.$_POST['rundistance'].'\', `kumite` = \''.$_POST['kumite'].'\', `kihon` = \''.$_POST['kihon'].'\', `skiprounds` = \''.$_POST['skiprounds'].'\', `skipDuration` = \''.$_POST['skipDuration'].'\', `bagRounds` = \''.$_POST['bagRounds'].'\', `bagDuration` = \''.$_POST['bagDuration'].'\', `complete` = \''.$_POST['complete'].'\', `selfDefence` = \''.$_POST['selfDefence'].'\', `duration1` = \''.$_POST['duration1'].'\', `runtimeMin` = \''.$_POST['runtimeMin'].'\', `runtimeSec` = \''.$_POST['runtimeSec'].'\', `fitnessTimeMin` = \''.$_POST['fitnessTimeMin'].'\', `fitnessTimeSec` = \''.$_POST['fitnessTimeSec'].'\', `rundistance1` = \''.$_POST['rundistance1'].'\' WHERE `session`.`id` = '.$_POST['id'];
echo ($sql);
//echo($_POST['rundistance1']);
if(!$mysqli){
$response_array['status'] = 'error';
print json_encode($response_array);
die("Connection failed: " . $mysqli->error);
}
//$sql = 'Select * FROM session WHERE id='.$_GET['Sid'];
///////
//ID,value,goal
//Pushup,120,150
//Situp, 100,150
//
//
//query to get data from the table
$query = sprintf($sql);
//execute query
$result = $mysqli->query($query);
//loop through the returned data
$data = array();
foreach ($result as $row) {
$data[] = $row;
}
//free memory associated with result
//$result->close();
//close connection
$mysqli->close();
//respond with success code
//now print the data
if ( $result === false ){
$response_array['status'] = 'error';
$response_array['data'] = 'mysql error';
}else{
$response_array['status'] = 'success';
}
print json_encode($response_array);
//print json_encode($data);
Test gist
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.