File "insert_db02.php"
Full Path: /home/analogde/www/Design/fileman/Fusion/Picker/insert_db02.php
File size: 7.12 KB
MIME-type: text/x-php
Charset: utf-8
<?php
include("database.php");
date_default_timezone_set('Europe/Paris');
include("fusioncharts.php");
$lili = db_connexion();
//print_r($lili);
//echo " ++++++ " .$conn;
// Read the JSON file
$json = file_get_contents('data.json');
// Decode the JSON file
$json_data = json_decode($json,true);
$status = AddTable($lili, "aabbcc");
if( $status == "CREATION")
{
echo "A FAIRE .....................";
echo "<br>";
}
if( $status == "DOUBLON")
{
echo "MEGA COOL";
echo "<br>";
//////InsertRecord($lili, "aabbcc" , $json_data);
}
for ($i = 0; $i < count($json_data); $i++)
{
//echo $json_data[$i][0] ." ****** " .$json_data[$i][1] ;
//echo "<br>";
$string = $json_data[$i][0];
$string = explode(')', (explode('(', $string)[1]))[0];
$str_less_spacing = str_replace(' ', '', $string);
echo $str_less_spacing . " -- " .strlen($str_less_spacing);
echo "<br>";
$valeur = $str_less_spacing;
$plage_date = $json_data[$i][1];
echo $valeur;
echo "<br>";
//echo strpos($string ,"*") . " " .$string;
//echo "<br>";
//$val = substr($string, 0, strpos($string ,"*") );
//echo $val;
//echo "<br>";
//$str = str_replace(' ', '', $val);
//echo strlen($str);
//echo "<br>";
//$open = strpos($string, "(");
//$close = strpos($string, ")");
//$text = substr($string, $open, $close-$open-1);
//echo $text;
//echo "<br>";
//$parts = explode("(", $string);
//$parts = explode(")", $parts[1]);
//echo $parts[0];
//echo "<br>";
}
// Display data
//echo "<pre>";
//print_r($json_data);
//echo "</pre>";
//print_r($lili);
// DBGetAllTables($lili);
echo "<br>";
echo "<br>";
echo "<br>";
$exists = "wp62_wfco_connectors";
$exists = "aaa_table";
// table_exists($lili, $exists);
// CreateTable($lili);
//Insert($lili, "aaaMyGuests");
echo "TRACE1";
echo "<br>";
// RecordExists($lili, "aaaMyGuests", "John");
echo "TRACE2";
echo "<br>";
$strQuery = "SELECT * FROM aabbcc; ";
$result = $lili->query($strQuery) or exit("Error code ({$lili->errno}): {$lili->error}");
if ($result)
{
echo "Ya de la data ....";
$arrData = array(
"chart" => array(
"caption"=> "blabla",
"xAxisname"=> "XXX",
"yAxisName"=> "YYY",
"numberPrefix"=> "",
"plotFillAlpha"=> "80",
"showValues"=> "1",
"placeValuesInside"=> "1",
"usePlotGradientColor"=> "0",
"rotateValues"=> "1",
"valueFontColor"=> "#FFFFFF",
"showHoverEffect"=> "1",
"rotateValues"=> "1",
"flatScrollBars"=> "1",
"numVisiblePlot"=> "3",
"showXAxisLine"=> "1",
"rotateLabels"=> "1",
"xAxisLineThickness"=> "1",
"xAxisLineColor"=> "#999999",
"showAlternateHGridColor"=> "0",
"legendBgAlpha"=> "0",
"legendBorderAlpha"=> "0",
"legendShadow"=> "0",
"legendItemFontSize"=> "10",
"legendItemFontColor"=> "#666666",
"theme"=> "fint"
)
);
$categoryArray=array();
$dataseries1=array();
$dataseries2=array();
while($row = mysqli_fetch_array($result))
{
//echo " " .$row["plage"] ." " .$row["valeur"];
//echo "<br>";
$val = "210";
array_push($categoryArray, array( "label" => $row["plage"]) );
array_push($dataseries1, array( "value" => $row["valeur"]) );
array_push($dataseries2, array( "value" => $val) );
}
$arrData["categories"]=array(array("category"=>$categoryArray));
$arrData["dataset"] = array(array("seriesName"=> "Prévision", "data"=>$dataseries1), array("seriesName"=> "Avancement", "data"=>$dataseries2));
echo "<pre>";
print_r($arrData);
echo "</pre>";
$jsonEncodedData = json_encode($arrData);
$burndown = new FusionCharts("scrollline2d", "chart1" , "70%", "1800", "contenu", "json", $jsonEncodedData);
//scrollline2d
$burndown->render();
echo "Fin";
echo "<br>";
echo "<br>";
echo "<br>";
}
/*for ($i = 0; $i < count($json_data); $i++)
{
echo $json_data[$i][0] ." ****** " .$json_data[$i][1] ;
echo "<br>";
}*/
/*
$exists = "client";
echo "alpha";
$result = $conn->query("SHOW TABLES LIKE '$exists'");
echo $result;
echo "jhjjkhjkkjk";
if($result->num_rows == 1) {
echo "Table exists";
} else {
echo "Table does not exist";
}
*/
// $exists = "wp62_wfco_connectors";
// table_exists($exists);
/*
$result = $conn->query("SHOW TABLES LIKE '$exists'");
if($result->num_rows == 1) {
echo "Table exists";
} else {
echo "Table does not exist";
}
// sql = "INSERT INTO users (name, email, password) VALUES (?,?,?)";
/*
$str_json = file_get_contents('php://input'); //($_POST doesn't work here)
$response = json_decode($str_json, true); // decoding received JSON to array
// json file name
//$filename = "transfert.json"; ???
// Read the JSON file in PHP
//$data = file_get_contents($filename); ???
//$json = json_encode(array('data' => $array));
//write json to file
if (file_put_contents("zzzzzdata.json", $str_json))
echo "JSON file created successfully...";
else
echo "Oops! Error creating json file...";
//echo "----> " .count($response);
// OK ABC
//echo " ----->>> " .$response[0][0];
// nombre de colonne dans $response[0]
//echo " ----->>> " .count($response[0]);
// lecture
echo "PHP recoit un objet de type " .gettype($response), "</br>";
echo "Nombre de colonne " .count($response), "</br>";
for ($i = 0; $i < count($response); $i++)
{
/*for ($j = 0; $j < count($response[$i]); $j++)
{
//echo "Nombre de ligne par colonne " .count($response[$j]), "</br>";
echo $response[$i][$j];
echo "<br>";
}*/
/*if(empty($response[$i]))
{
echo "Empty string " .$response[$i];
}
else
{
echo "Not empty " .$response[$i];
} */
/*
echo $response[$i][0] ." ****** " .$response[$i][1] ;
echo "<br>";
}
//var_dump($response);
// https://www.w3docs.com/snippets/php/save-php-array-to-mysql.html
// serialize
*/
?>
<html>
<head>
<title>FusionCharts | Multi-Series Chart using PHP and MySQL</title>
<!--
<script src="http://static.fusioncharts.com/code/latest/fusioncharts.js"></script>
<script src="http://static.fusioncharts.com/code/latest/fusioncharts.charts.js"></script>
<script src="http://static.fusioncharts.com/code/latest/themes/fusioncharts.theme.fint.js"></script>
-->
<script src="js/js/fusioncharts.js"></script>
<script src="js/js/fusioncharts.charts.js"></script>
<script src="js/js/themes/fusioncharts.theme.fint.js"></script>
</head>
<body>
<center>
<div id="contenu"> 3 Chart will render here!</div>
</center>
</body>
</html>