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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:51:08+00:00 2026-05-27T20:51:08+00:00

I know this has been asked before, and I know you can do it

  • 0

I know this has been asked before, and I know you can do it via making a seprate page for each image. But thats not ideal for what I want.

I want to do that age old thing of displaying multiple images from a db on the same page:

echo "<table>";
echo "<tr class ='tablehead'><td>Name</td><td>Location</td><td>Review</td><td>Image</td><td>Thumb</td></tr>";

while ($row = mysql_fetch_array($query))
{   
    echo "<tr>";
    echo "<td>" . $row['user_fname'] . "</td>";
    echo "<td>" . $row['user_location'] . "</td>";
    echo "<td>" . $row['user_review'] . "</td>";
    echo "<td>" . $row['user_image'] . "</td>";
    echo "<td>" . $row['user_thumb'] . "</td>";
    echo "</tr>";
}

echo "</table>";

user_image and user_thumb are blob images, is there someway of showing them all on that page, perhaps setting them to a php variable and then converting to javascript or something along those lines? Rather than:

  header('Content-type: image/jpg');
  echo $thumb;

In a seperate file?

  • 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-05-27T20:51:09+00:00Added an answer on May 27, 2026 at 8:51 pm

    You have basically two problems here:

    1. As $thumb contains the binary data of the image, the browser will not understand it unless you tell the browser what data it is (e.g. image/jpg).

    2. You need to tell the browser where the data is.

    Let’s say you want to create an image displaying the thumb in that page:

    <td><img src="..." alt="thumb"></td>
    

    The src attribute tells the browser where it can find the data of the image. So it is used to solve problem 2. It expects an Uniform Resource Locator (URI).

    So how to get the $thumb into an URI? There are multiple ways to do that, including the one linked in a comment.

    However, if the image is not very large and you don’t need to have it cached specifically (e.g. the HTML should be cached, but not the thumb image), you can make use of a data: URI Scheme­Wikipedia:

    $thumbSrc = 'data:image/jpg;base64,'.base64_encode($thumb);
    

    You then can output that variable as the src attribute’s value:

    <td><img src="<?php echo $thumbSrc; ?>" alt="thumb"></td>   
    

    Hope this is helpful.

    Complete answer:

    echo "<table>";
        echo "<tr class ='tablehead'><td>Name</td><td>Location</td><td>Review</td><td>Image</td><td>Thumb</td></tr>";
        while ($row = mysql_fetch_array($query))
        {   
            echo "<tr>";
                echo "<td>" . $row['user_fname'] . "</td>";
                echo "<td>" . $row['user_location'] . "</td>";
                echo "<td>" . $row['user_review'] . "</td>";                    
                echo '<td><img src="data:image/jpg;base64,', base64_encode($row['user_thumb']), '" alt='thumb'></td>'; 
                echo '<td><img src="data:image/jpg;base64,', base64_encode($row['user_image']), '" alt='image'></td>';
            echo "</tr>";
        }
    echo "</table>";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know this has probably been asked before, but I can't find it with
I know this has probably been asked before but I can't seem to find
I know this question has been asked before, but I tried eveything and can't
I know this has been asked before, but i can't find a good answer
I know this has been asked before but I can't find it so... Say
I know this has been asked several times before but I can't seem to
I know that maybe this question has been asked before, but I can't seem
I know this has been asked before, but I've found a different way to
Ok, I know this has been asked before but after searching I couldn't find
I know this question has been asked before, but I ran into a problem.

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.