Last active
December 18, 2015 20:27
-
-
Save vvikramjhu/a6c33a2035774fd6d610 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//$username = $config["database_connection"]["username"]; | |
//$password = $config["database_connection"]["password"]; | |
//$host = $config["database_connection"]["database_hostname"]; | |
//$database_name = $config["database_connection"]["database_name"]; | |
//$port = $config["database_connection"]["port"]; | |
$username = "root"; | |
$password = "xyz"; | |
$database_name = "test"; | |
$host = "localhost"; | |
$port = "3306"; | |
if($host == ""){ | |
$host = "127.0.0.1"; | |
} | |
if($port == ""){ | |
$port = "3306"; | |
} | |
$port = intval($port); | |
$mysqli = new mysqli($host, $username, $password, $database_name, $port); | |
if ($mysqli->connect_errno) { | |
$error_string = sprintf("Connect failed: %s\n", $mysqli->connect_error); | |
echo "hello world"; | |
//echo error_log($error_string, 0); | |
} | |
$key = ""; | |
$value = ""; | |
$staticData = array(); | |
$sql = "select demo_variable, demo_hard_coded_value from test.dashboard"; | |
$stmt = $mysqli->prepare($sql); | |
$stmt->execute(); | |
$stmt->bind_result($key, $value); | |
//$stmt->fetch(); | |
while($stmt->fetch()){ | |
$staticData[$key] = json_decode($value); | |
} | |
$stmt->free_result(); | |
$stmt->close(); | |
// another example of fetch | |
//$public_names = array(); | |
//while($stmt->fetch()){ | |
// $public_names[] = $public_name; | |
//} | |
//$stmt->close(); | |
//return $public_names ; | |
//$staticData = file_get_contents('dashboardData.json'); | |
//echo ($staticData); | |
echo json_encode($staticData); | |
// OBTAINED result on the xhr get | |
// {"MyTasks":["130\/200","width: 65%;"],"sparks":null} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
insert into dashboard(demo_variable, demo_hard_coded_value) values('sparks','["$47,171", "1300, 1877, 2500, 2577, 2000, 2100, 3000, 2700, 3631, 2471, 2700, 3631, 2471", "<i class=\"fa fa-arrow-circle-up\"></i> 45%", "110,150,300,130,400,240,220,310,220,300, 270, 210","<i class=\"fa fa-shopping-cart\"></i> 2447", "110,150,300,130,400,240,220,310,220,300, 270, 210"]'); | |
insert into dashboard(demo_variable, demo_hard_coded_value) values('MyTasks','["130/200", "width: 65%;"]'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment