I am trying to save the variable score in the $chartdata[0] array. If I put in a regular value let’s say “20”, i have no problem. However, when I try to reference the $score variable the values do not get stored in the array. It works fine if I use the random function and even when I echo out score I can see my values coming out fine. What am I doing wrong?
while ($i < 5) {
$date=mysql_result($result,$i,"date");
$score=mysql_result($result,$i,"rating_score");
echo $score;
$chartData[0][] = $score;
$chartData[1][] = rand(250,4000);
$chartData[2][] = rand(250,4000);
$categories[$i] = 'Label-' . $i;
$i++;
}
The page is here: http://www.thelocalgolfer.com/chart/
Not that I fully see the sense of your code (as you simply overwrite
$chartDataall the time so what’s left when loop is done is last entry score and rands), but answering your question: instead ofdo this
When you are lost with arrays using
print_r()orvar_dump()on them usually helps to see what is really inside (i preferprint_r()if I do not care content, due to formatting)