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

  • Home
  • SEARCH
  • 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 8994689
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:29:19+00:00 2026-06-15T23:29:19+00:00

My code is a bit complex for generating the image array but the general

  • 0

My code is a bit complex for generating the image array but the general idea is to create 8 pie charts that then need to be displayed in a column of charts in a table. What am I doing wrong to get the images down in my html. This function is located in the same file as the html.

building the images

$FileHandle = fopen($FileName, 'r') or die("can't open file!!");

//Getting total for each question
$i = 0;
$start = 0;
$finish = 0;

while (($row = fgetcsv($FileHandle, 1024, ",")) !== FALSE) {
    $total[] = $row[0] + $row[1] + $row[2] + $row[3] + $row[4];
    $average[] = round(((1 * $row[0] + 2 * $row[1] + 3 * $row[2] + 4 * $row[3] + 5 * $row[4]) / $total[$i]), 2, PHP_ROUND_HALF_UP);

    $start = 0;
    $finish = 0;

    $myImage[$i] = ImageCreate(200, 200);

    $white = ImageColorAllocate($myImage[$i], 255, 255, 255);
    $red = ImageColorAllocate($myImage[$i], 255, 0, 0);
    $orange = ImageColorAllocate($myImage[$i], 191, 64, 0);
    $olive = ImageColorAllocate($myImage[$i], 128, 128, 0);
    $green = ImageColorAllocate($myImage[$i], 64, 191, 0);
    $lt_green = ImageColorAllocate($myImage[$i], 0, 255, 0);

    $finish = ($row[0] / $total[$i]) * 360;
    //echo $start . ' ' . $finish . '<br>';
    if ($finish != $start) {
    ImageFilledArc($myImage[$i], 100, 100, 50, 50, $start, $finish, $red, IMG_ARC_PIE);
    $start = $finish;
    $finish += ($row[1] / $total[$i]) * 360;
    }
else{
    $start = $finish;
        $finish += ($row[1] / $total[$i]) * 360;
}
    if ($finish != $start) {
        ImageFilledArc($myImage[$i], 100, 100, 50, 50, $start, $finish, $orange, IMG_ARC_PIE);
        $start = $finish;
        $finish += ($row[2] / $total[$i]) * 360;
    }
    else{
        $start = $finish;
        $finish += ($row[2] / $total[$i]) * 360;
    }
    if ($finish != $start) {
        ImageFilledArc($myImage[$i], 100, 100, 50, 50, $start, $finish, $olive, IMG_ARC_PIE);
        $start = $finish;
        $finish += ($row[3] / $total[$i]) * 360;
    }
    else{
        $start = $finish;
        $finish += ($row[3] / $total[$i]) * 360;
    }
    if ($finish != $start) {
        ImageFilledArc($myImage[$i], 100, 100, 50, 50, $start, $finish, $green, IMG_ARC_PIE);
        $start = $finish;
        $finish += ($row[4] / $total[$i]) * 360;
    }
    else{
        $start = $finish;
        $finish += ($row[4] / $total[$i]) * 360;
    }
    if ($finish != $start) {
        ImageFilledArc($myImage[$i], 100, 100, 50, 50, $start, $finish, $lt_green, IMG_ARC_PIE);
    }
    $i++;
}

and here is what i tried down in the html block

<td><?php echo $average[0] ?></td>
<td><?php imagepng($myImage[0]); ?></td>
<td><?php echo $total[0] ?></td>
  • 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-15T23:29:20+00:00Added an answer on June 15, 2026 at 11:29 pm

    Had to use a separate file for the image generation and call it with

    <img src = "chart.php">
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My problem is a bit more complex than using the following simple JavaScript code:
I need to integrate some legacy 32-bit code - for which I don't have
This bit of code comes with new classes that are subclasses of UITableViewController... -
The following bit of code works great in everything but IE. In IE, the
This is a bit complex. I've created an array (NSArray) called pointsOfInterest. The elements
My problem is a little bit complex. I have the following code: $(document).ready(function() {
ok i got this problem. i have this routes: (code bit change) File:/home/dotcloud/current/config/routes.js exports.routes
using Matt's util code (a bit edited for Unicode text) public class GridViewExportUtil {
I'm attempting to assemble some 32-bit code using NASM and GCC on a 64-bit
I'm looking for strategies and articles on making Carbon code 64-bit ready. Carbon for

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.