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 8122755
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T05:56:04+00:00 2026-06-06T05:56:04+00:00

Please excuse my newbie Question. I’m tryin to display data from a mysql table

  • 0

Please excuse my newbie Question.

I’m tryin to display data from a mysql table into a chart (phpChart http://phpchart.net)
What I need is to display all values of Field cost for Region ‘CA’

E.g

ID  Cost  Region
----------
1   500    CA
----------
2   100    DP
----------
3   280    CA
----------
4   40     ST
----------
5   80     CA
----------

<?php
include 'config.php';
$query = "SELECT Cost From tblForecast where Region='CA' =";
$rs = mysql_query($query);

if (!$rs) {
    echo "Could not execute query: $query";
    trigger_error(mysql_error(), E_USER_ERROR); 
} else {
    echo "Query: $query executed\n";
} 

$nrows = mysql_num_rows($rs);

for ($i = 0; $i < $nrows; $i++) {
    $row = mysql_fetch_row($rs);
    echo $row[0];
    echo "<br/>";
}

$pc = new C_PhpChartX(array(array($row[0])),'basic_chart');
\\"This where i'm stuck as to how display the other values within the array"

$pc->set_title(array('text'=>'Basic Chart with Bar Renderer'));
$pc->set_series_default(array('renderer'=>'plugin::BarRenderer'));

$pc->draw();
mysql_close();

?>

I’m able to display the first rows value in the chart only.

Anyone’s help would be much appreciated
Thanks in advance

  • 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-06T05:56:06+00:00Added an answer on June 6, 2026 at 5:56 am

    You’re continually fetching your query results into a single variable, and overwriting that data on each iteration of the loop.

    Try this:

    $data = array();
    while ($row = mysql_fetch_array($rs)) {
       $data[] = $row[0];
    }
    
    $pc = new C_PhpChartX($data, 'basic_chart');
    

    Plus, though this is most likely on a cut/paste type, you’ve got a syntax error in your query anyways:

    $query = "SELECT Cost From tblForecast where Region='CA' =";
                                                             ^---syntax error
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am a patterns newbie so please excuse this question if it sounds too
Please excuse the newbie question but I was wondering if I used Linq in
I am a newbie. please excuse me if it is a very basic question.
Excuse my iPhone/Objective-C newbie status please! I've found my HTTP server using NSNetServiceBrowser, but
I'm very new to F# so please excuse the completely newbie question: I have
Ok, I'm an MVC newbie coming from a webforms background, so please excuse any
I am a newbie with html so please excuse me if the question is
please excuse the Rail noob question. I'm trying to display a list of associated
iam newbie here.. please execuse if iam asking wrong question here. iam developing dynamic
I am a newbie in this field so please excuse my silly mistakes :)

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.