I am trying to display a pie chart that shows the results of my query. In this sample I have 3 time periods (Breakfast, Lunch, Dinner) and count how many records I have for each period. When displaying the chart though, I need to have each dataset with a different color, which is why I added an IF statement while fetching results.
Naturally, the statement is not working and only returns the color for "breakfast". How can I refresh the statement to check each returned row for the Period name and then echo the respective color?
Thanks
while($row = mysqli_fetch_array($result)){
$count = $row['period_count'];
$period = $row['period'];
if ($period = "Breakfast") {
$color = "#F38630";
} elseif ($period = "Lunch") {
$color = "#E0E4CC";
} else {
$color = "#69D2E7";
}
echo "{"."\n";
echo "value : " . $row['period_count'] . ","."\n";
echo "color : \"" . $color ."\","."\n";
echo "label : \"" . $row['period']."\""."\n";
echo "},"."\n";
}
==operator.if ($period == "Breakfast") {