Display Dynamic image along with text on the same webpage

Discussion in 'PHP' started by nitint, Oct 17, 2008.

  1. #1
    Hi,
    I would hope to find some answers to my problem the details are given below.
    Please help me

    Setup Details:
    I have set up GD sitting on php and having mysql as my database.

    Issue
    I would like to display some text along with a table (the data will come from mysql), and also a graph (pie chart or bar chart, using GD) in the same webpage.
    Every user who logs in has different data and hence different graphs.

    Right now i am creating a image file in server (jpeg/png doesn't really matter) and then displaying the image. The code is as shown below.

    Imagejpeg($handle,"report.jpeg",100);
    imagedestroy($handle);
    echo "<img src='report.jpeg'><p></p>";
    ................................
    ?>

    This above code creates a image file in the server and as there are many users i can not afford to create and store the image for all the users.

    If i try to display image dynamically(without actullay creating a image file) i am seeing junk caracters. My guess is this issue is be related to content-type in a webpage.

    I would like to know if there is any way that i can display the image without actually creating a file in server.

    Thanks in anticipation of your help.
    Nitin
     
    nitint, Oct 17, 2008 IP
  2. EricBruggema

    EricBruggema Well-Known Member

    Messages:
    1,740
    Likes Received:
    28
    Best Answers:
    13
    Trophy Points:
    175
    #2
    create a external script that displays the image, instead of creating the image and displaying it in the same script!
     
    EricBruggema, Oct 17, 2008 IP
  3. jmatthew3

    jmatthew3 Peon

    Messages:
    29
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    make a script, image.php

    make that script do:

    header('Content-type: image/jpeg');
    Imagejpeg($handle,"report.jpeg",100);
    imagedestroy($handle);

    then in your main html code, put <img src="image.php"/>
     
    jmatthew3, Oct 17, 2008 IP
  4. nitint

    nitint Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Thanks for your help, your suggestion really solved the issue.
     
    nitint, Oct 19, 2008 IP