Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8659565
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T16:02:42+00:00 2026-06-12T16:02:42+00:00

I am trying to save the variable score in the $chartdata[0] array. If I

  • 0

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/

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T16:02:43+00:00Added an answer on June 12, 2026 at 4:02 pm

    Not that I fully see the sense of your code (as you simply overwrite $chartData all the time so what’s left when loop is done is last entry score and rands), but answering your question: instead of

    $chartData[0][] = $score;
    $chartData[1][] = rand(250,4000);
    $chartData[2][] = rand(250,4000);
    

    do this

    $chartData[0][] = $score;
    $chartData[0][] = rand(250,4000);
    $chartData[0][] = rand(250,4000);
    

    When you are lost with arrays using print_r() or var_dump() on them usually helps to see what is really inside (i prefer print_r() if I do not care content, due to formatting)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to save a button's location in a variable, but I have no
I'm trying to save the returned data from HTTP request into a variable. The
I'm trying to save some data into an array but unfortunately all the data
I'm trying to save a logged in user's score to my sql database. I
I have multiple variables in a shell script; i was trying to save some
I'm trying to save a string variable from my FolderBrowserDialog.SelectedPath(). Using a breakpoint I
I'm trying to save some time / make my code readable. I have a
I am trying to save a global variable in my module and access it
We are trying to track down the cause of a performance problem. We have
I'm trying to save a TimeSpan variable from VB into a SQL database, into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.