php db new PDO mysql host 127 dbname kek root test db- query SELECT ke

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
<?php
$db = new PDO('mysql:host=127.0.0.1;dbname=kek', 'root', '');
$test = $db->query('SELECT `key` FROM `test`')->fetchAll();
$array = [];
$average = 0;
foreach($test as $key => $data){
$value = sin($data['key']);
$average += $value;
$array[] = $value;
}
$average = $average / count($array);
echo $average;
?>