/    Sign up×
Community /Pin to ProfileBookmark

passing variable to an array

Hi,
I am using google visualization api script from phpclasses site.
Below is a sample fiile script for outputing in pie chart form.
I would like to replace the figures in the setValues with a variable that i am getting from a function i made. The function is successfully printing the value
and saved in a variable.
for example:

[code=php]$i_support = Print_no_of_Support($rid,$gid);
echo “$i_support “; //prints 2
[/code]

but once i replace it with the values below in the SetValue section, the graph does not work.
However, if i assign any variable to a number like this: $s = 10;
then, it will work. Even though i printed the $i_support variable .
?
Anyway, here is the code

[code=php]<html>
<head>
</head>

<body>
<?php

include_once ‘config.inc.php’;

$chart = new QPiechartGoogleGraph;
$chart ->addDrawProperties(
array(
“title”=>’General Visualization’,
)
)
->addColumns(
array(
array(‘string’, ‘Task’),
array(‘number’, ‘Hours per Day’)
)
)
->setValues(
array(
array(0, 0, ‘Work’),
array(0, 1, 11),
array(1, 0, ‘Eat’),
array(1, 1, 2),
array(2, 0, ‘Commute’),
array(2, 1, 2),
array(3, 0, ‘Watch TV’),
array(3, 1, 2),
)
);
echo $chart->render();

echo $chart->getReferenceLink();

?></body>
</html>[/code]

anyone got idea ???

to post a comment
PHP

0Be the first to comment 😎

×

Success!

Help @themoon spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...