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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:23:49+00:00 2026-06-13T13:23:49+00:00

I want to have a Print This Image button on the page where the

  • 0

I want to have a “Print This Image” button on the page where the image is generated. Ive tried putting html code on my image.php file(see codes below) but it wont show. Some people said to try separating the html and php code. Ive tried using the <img src="image.php" alt="" /> code on another file called generated.php but all I get is a broken image. Please help! 🙁

Here is the code of my image.php file:

$num_fields = $_POST['num_fields'];
// create image
$image = imagecreate(500, 500);

// allocate some colors
$white    = imagecolorallocate($image, 255, 255, 255);
$pink     = imagecolorallocate($image, 255, 105, 180);
$red = imagecolorallocate($image, 255, 000, 000);
$green     = imagecolorallocate($image, 034, 139, 034);
$brown = imagecolorallocate($image, 139, 069, 019);
$yellow      = imagecolorallocate($image, 255, 255, 000);
$orange  = imagecolorallocate($image, 255, 140, 000);
$blue  = imagecolorallocate($image, 100, 149, 237);
$purple  = imagecolorallocate($image, 218, 112, 214);
$gray  = imagecolorallocate($image, 205, 205, 193);
$black    = imagecolorallocate($image, 000, 000, 000);
$cyan    = imagecolorallocate($image, 000, 255, 255);


//bg color//
imagefilledrectangle($image,0,0,500,500,$white);

$font = 'arial.ttf'; 

if($num_fields =='6')
{ 
// for each slices
imagefilledarc($image, 250, 250, $_POST['rating-1'], $_POST['rating-1'], 0, 60, $pink, IMG_ARC_EDGED);
imagefilledarc($image, 250, 250, $_POST['rating-2'], $_POST['rating-2'], 60, 120 , $green, IMG_ARC_EDGED);
imagefilledarc($image, 250, 250, $_POST['rating-3'], $_POST['rating-3'], 120, 180 , $red, IMG_ARC_EDGED);
imagefilledarc($image, 250, 250, $_POST['rating-4'], $_POST['rating-4'], 180, 240 , $gray, IMG_ARC_EDGED);
imagefilledarc($image, 250, 250, $_POST['rating-5'], $_POST['rating-5'], 240, 300 , $orange, IMG_ARC_EDGED);
imagefilledarc($image, 250, 250, $_POST['rating-6'], $_POST['rating-6'], 300, 360 , $blue, IMG_ARC_EDGED);


//outline
imagefilledarc($image, 250, 250, 400, 400, 0,360, $black, IMG_ARC_NOFILL); //outer circle
imagefilledarc($image, 250, 250, 320, 320, 0,360, $black, IMG_ARC_NOFILL); //inner circle
imageline($image, 250, 250, 450, 250, $black ); //line bet blue and pink 0 deg
imageline($image, 250, 250, 349, 78, $black ); //line bet orange and blue
imageline($image, 250, 250, 150, 78, $black ); //line bet orange and gray 
imageline($image, 250, 250, 50, 250, $black ); //line bet red and gray 
imageline($image, 250, 250, 151, 422, $black ); //line bet red and green 
imageline($image, 250, 250, 350, 422, $black ); //line bet pink and green 


//text legends 2
imagettftext($image, 9, 243, 425, 280, $black, $font, $_POST['field-1']);
imagettftext($image, 9, 183, 315, 415, $black, $font, $_POST['field-2']);
imagettftext($image, 9, 120, 130, 380, $black, $font, $_POST['field-3']);
imagettftext($image, 9, 60, 75, 210, $black, $font, $_POST['field-4']);
imagettftext($image, 9,0, 200, 80, $black, $font, $_POST['field-5']);
imagettftext($image, 9, 300, 378, 128, $black, $font, $_POST['field-6']);


// flush image
header('Content-type: image/png');
imagepng($image);
imagedestroy($image);   
}
  • 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-13T13:23:49+00:00Added an answer on June 13, 2026 at 1:23 pm

    It is a bit unclear to me what you want, but… The code you are showing is just making the image. In addition to this, you need an html page made by some scripting language that forwards the queries to your image.php e.g. (this is quite old fashioned php-coding and looks ugly, but it should work)

    <html>
    <head><title>My image</title></head>
    <body>
    <img src="image.php?<?php
        print"num_fields=${_POST['num_fields']}&rating-1=${_POST['rating-1']}&rating-2=${_POST['rating-2']}&rating-3=${_POST['rating-3']}&rating-4=${_POST['rating-4']}&rating-5=${_POST['rating-5']}&rating-6=${_POST['rating-6']}&field-1=${_POST['field-1']}&field-2=${_POST['field-2']}&field-3=${_POST['field-3']}&field-4=${_POST['field-4']}&field-5=${_POST['field-5']}&field-6=${_POST['field-6']}"
    ?>
    " alt="" /> 
    </body>
    </html>
    

    (The “My image” part may of course be anything you like as a title for your page)

    Now you can start to add on something more between the and tags. If you add some html output in the file you have now, it will either be ignored or it will make your image invalid.

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

Sidebar

Related Questions

I have an html page i want to print a portion of this html
I have this piece of code in a function. I want to print the
I have added a print button to my page. <button type=button class=printBtn>Print This Page</button>
I have this webservice snippet and i want to print the actual value returned.
I have this code that I want to make point-free; (\k t -> chr
Say I have the code: print(>>> ) command = gets What I want to
I have this code on my print.css: #header, #tae, #nav, .noprint {display: none;} width:
I have the string "re\x{0301}sume\x{0301}" (which prints like this: résumé) and I want to
I have a string: # print thestring abcd\t$500\n I want to extract the dollar
I have an array in Perl I want to print with space delimiters between

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.