mysql — PHP холст JS X и Y значения не извлекаются

Как видно из кода ниже, мои X-переменные — это 12 месяцев в моей базе данных, на которые ссылается код. Я не могу найти решение, которое позволяет мне помечать X-переменные из месяцев и Y-переменные как диапазон оценок от 0 до 10, и функцию, то есть строку, называемую std_id.

<?php
/* AFTER LOGIN HOME PAGE*/
require 'conn.php';

session_start();
?>
<?php
$dataPoints = array();
//Best practice is to create a separate file for handling connection to database
try{
// Creating a new connection.
// Replace your-hostname, your-db, your-username, your-password according to your database
$link = new \PDO(   'mysql:host=localhost;dbname=tik;charset=utf8mb4', //'mysql:host=localhost;dbname=canvasjs_db;charset=utf8mb4',
'root', //'root',
'', //'',
array(
\PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
\PDO::ATTR_PERSISTENT => false
)
);

$handle = $link->prepare('select x, y from perfedetails');
$handle->execute();
$result = $handle->fetchAll(\PDO::FETCH_OBJ);

foreach($result as $row){
array_push($dataPoints, array("x"=> $row->x, "y"=> $row->y));
}
$link = null;
}
catch(\PDOException $ex){
print($ex->getMessage());
}
?>
<!DOCTYPE html>

<html>
<head>

<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Student Performance Chart</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link href="https://fonts.googleapis.com/css?family=Dosis|Lato|Open+Sans|Oswald|Raleway|Roboto" rel="stylesheet">
<link rel = "stylesheet" type = "text/css" href = "Style.css" />
<script>
window.onload = function () {

var chart = new CanvasJS.Chart("chartContainer", {
animationEnabled: true,
exportEnabled: true,
theme: "light1", // "light1", "light2", "dark1", "dark2"title:{
text: "PHP Column Chart from Database"},
data: [{
type: "column", //change type to bar, line, area, pie, etc
dataPoints: <?php echo json_encode($dataPoints, JSON_NUMERIC_CHECK); ?>
}]
});
chart.render();

}
</script>
</head>
<body>


<div id="container">
<section>
<h1>Student Performance Chart</h1>
<div class="tbl-header">
<table cellpadding="0" cellspacing="0" border="0">
<thead>
<tr>
<th class="weirdind">ID</th>
<th class="weirdind">NAME</th>
<th class="weirdind">January</th>
<th class="weirdind">Feburary</th>
<th class="weirdind">March</th>
<th class="weirdind">April</th>
<th class="weirdind">May</th>
<th class="weirdind">June</th>
<th class="weirdind">July</th>
<th class="weirdind">August</th>
<th class="weirdind">September</th>
<th class="weirdind">October</th>
<th class="weirdind">November</th>
<th class="weirdind">December</th>
<th class="weirdind">Perf_grade</th>
</tr>
</thead>
</table>
</div>



<div id="chartContainer" style="height: 370px; width: 100%;"></div>
<script src="https://canvasjs.com/assets/script/canvasjs.min.js"></script>


</body>
</html>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>

Код базы данных

-- phpMyAdmin SQL Dump
-- version 4.7.0
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Mar 22, 2018 at 08:09 AM
-- Server version: 10.1.25-MariaDB
-- PHP Version: 7.1.7

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+00:00";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;

--
-- Database: `tik`
--

-- --------------------------------------------------------

--
-- Table structure for table `perfedetails`
--

CREATE TABLE `perfedetails` (
`std_id` int(5) NOT NULL,
`std_name` varchar(40) NOT NULL,
`January` int(1) DEFAULT '0',
`Feburary` int(1) DEFAULT '0',
`March` int(1) NOT NULL DEFAULT '0',
`April` int(1) NOT NULL DEFAULT '0',
`May` int(1) NOT NULL DEFAULT '0',
`June` int(1) NOT NULL DEFAULT '0',
`July` int(1) NOT NULL DEFAULT '0',
`August` int(1) NOT NULL DEFAULT '0',
`September` int(1) NOT NULL DEFAULT '0',
`October` int(1) NOT NULL DEFAULT '0',
`November` int(1) NOT NULL DEFAULT '0',
`December` int(1) NOT NULL DEFAULT '0',
`perf_grade` int(1) NOT NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `perfedetails`
--

INSERT INTO `perfedetails` (`std_id`, `std_name`, `January`, `Feburary`, `March`, `April`, `May`, `June`, `July`, `August`, `September`, `October`, `November`, `December`, `perf_grade`) VALUES
(12345, 'Lorem Ipsum', 5, 3, 5, 6, 7, 6, 5, 7, 8, 9, 9, 8, 0),
(12346, 'Liet Kiley', 4, 4, 4, 5, 6, 5, 6, 6, 5, 4, 3, 3, 0),
(12347, 'Biket Doil', 5, 5, 5, 6, 7, 7, 6, 8, 9, 8, 8, 7, 0),
(12348, 'Diet Kilet', 7, 7, 6, 8, 8, 7, 6, 8, 7, 6, 7, 8, 0),
(12349, 'Adit Garg', 2, 5, 3, 6, 3, 6, 7, 8, 5, 4, 9, 6, 5),
(12350, 'Samyak kumar', 8, 7, 8, 7, 6, 7, 6, 9, 8, 8, 9, 8, 0),
(12351, 'Jai Singh', 7, 6, 7, 8, 6, 5, 6, 6, 7, 6, 5, 6, 0),
(12352, 'Hardik Kilet', 7, 6, 7, 7, 6, 8, 8, 8, 7, 7, 6, 6, 0),
(12353, 'Irene West', 6, 6, 7, 6, 8, 6, 8, 5, 7, 8, 6, 8, 0),
(12354, 'James Druid', 8, 7, 8, 8, 7, 8, 9, 8, 7, 7, 8, 8, 0);

--
-- Indexes for dumped tables
--

--
-- Indexes for table `perfedetails`
--
ALTER TABLE `perfedetails`
ADD PRIMARY KEY (`std_id`,`std_name`);
COMMIT;

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

0

Решение

Задача ещё не решена.

Другие решения

Других решений пока нет …

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector