Jump to content

inserting decimals in an array with array_push


sanaini

Recommended Posts

Hello everyone,

This one has been killing me for a while.

I am creating a pie chart with JPGraphs. I'm inserting minutes to be displayed right now, but I would like to convert them into hours to show. When I do so, it shows 0. I suppose since the number of minutes is less than an hour, and it does not display decimal points.

This is my code snippet

$xdata=array();
$ydata=array();
$xlables=array();
if($num_rows>=1){
$row=mysql_fetch_assoc($result);
do{
        $mins= $row['minutes'];
        $divider = doubleval(60);
        $hrs = $mins/$divider;
        array_push($xdata,$mins);
        array_push($ydata,trim($row['parent_task_name']));
        $name=$rowName['ln'];
} while($row = mysql_fetch_assoc($result));
}

Can someone please let me know how to fix this. I'm assuming it messes up once it enters the array. Becasue I did an echo of every step and it shows the values right, but once in the array, the chart shows 0.

 

Thanks a lot,

-Seyed

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.