1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
|
<?php
$con = mysqli_connect("localhost","root","","mydb");
if (!$con) {
die('Could not connect: ' . mysqli_connect_error());
}
$name="D22895A";
mysqli_query($con,"SET NAMES 'utf8'");
mysqli_query($con,'SET CHARACTER SET utf8');
$query1='SELECT hour FROM donnees
WHERE name = ?
';
$sth = mysqli_prepare($con,$query1);
mysqli_stmt_bind_param($sth,"s",$namecell);
mysqli_stmt_execute($sth);
$rows = array();
$rows['name'] = 'hour';
while($r = mysqli_stmt_fetch($sth)) {
$rows['data'][] = $r['hour'];
}
$query2='SELECT KPI FROM donnees
WHERE name= ?
';
$sth = mysqli_prepare($con,$query2);
mysqli_stmt_bind_param($sth,"s",$name);
mysqli_stmt_execute($sth);
$rows1 = array();
$rows1['name'] = 'Initial';
while($rr = mysqli_stmt_fetch($sth)) {
$rows1['data'][] = $rr['KPI'];
}
$result = array();
array_push($result,$rows);
array_push($result,$rows1);
print json_encode($result,JSON_NUMERIC_CHECK);
mysqli_close($con);
?> |
Partager