I am trying to push json encoded form my database select into chart.js data set but im not sure how to go about it without over engineering it.
Here is a simple select of scores from its retrospective table:
if($teamData == 0){
$allTeams = 'All';
} else{
$sql = "SELECT * FROM compScore WHERE memberId = 1";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
$jsonScores = json_encode($row, JSON_PRETTY_PRINT);
}
}
}
header('Content-type: application/json');
echo $jsonScores;
the output of this is:
{ "id": "1", "score1": "2", "score2": "3", "score3": "5", "score4": "4", "score5": "3", "score6": "2", "score7": "1", "score8": "3", "memberId": "1" }
I have one issue where it only fetches 1 record and I also want to exclude the field memberId
Even more so how do I push that result into:
datasets : [
{
fillColor: "rgba(102,45,145,.1)",
strokeColor: "rgba(102,45,145,1)",
pointColor : "rgba(220,220,220,1)",
pointStrokeColor : "#fff",
data : [] // HERE IS WHERE THE DATA NEEDS TO GO
}