Jump to content

Can't get BLOB field to show up


tharden3

Recommended Posts

hey PHPfreaks, I've just joined and I'm looking forward to expanding my knowledge with the help of all of you great people out there. Nice to meet you all.

 

Here is my problem:

I'm making a website with lists of products on it. It shows 10 or 12 products per page, and each product has 3 varchar fields (for the products information), and one BLOB field (for a product thumbnail). I can get the varchar fields to show up, but the BLOB field won't. "imgdata" is where the binary (BLOB) for the images are stored. Here is my code:

$query = " SELECT * FROM air_registers" .
         " LIMIT $offset, $rowsPerPage";
$result = mysql_query($query) or die('Error, query failed');

while($row=mysql_fetch_array($result, MYSQL_ASSOC)){
   $imgdata=$row["imgdata"];
   $type=$row["Type"];
   $number=$row["Number"];
   $desc=$row["Description"];
   echo "<div id='type'><strong>Model Type: </strong>$type</div>";
   echo "<div id='number'><strong>Model #: </strong>$number</div>";
   echo "<br />";
   echo $imgdata;
   echo "<br />";
   echo "<div id='desc'><strong>Description: </strong>$desc</div>";
   echo "<br />";
   echo "<hr>";
}

 

Thanks for the help everyone.

Link to comment
Share on other sites

Every image on a web page needs an <img src="url_of_the_image" alt=""> tag - http://w3schools.com/html/html_images.asp

 

This is yet another reason why files should not be stored in databases. If your thumbnails were files stored in a folder, all you would need to do is put the URL of the thumbnail into the <img src="..." tag.

 

Since you have files stored in a database, the URL that you put into the <img src="..." tag needs to be that of a .php file that queries the database and outputs the correct content type header for the image followed by the image data.

Link to comment
Share on other sites

Hey PFMaBiSmAd, thanks for the help.

 

I've been told this before, but I have a lot of pictures, and it seemed necessary. At some point though, I need some sort of PHP script to run through either the images, or their address, and use an img tag. I'm not quite sure how to do this. Any suggestions?

 

Thanks,

      Tim

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.