Skip to main content
Participating Frequently
April 13, 2010
Answered

Can someone help with how to get image

  • April 13, 2010
  • 1 reply
  • 613 views

from a database into a display page using Dreamweaver?

I have a page with a recordset and a database with text and images. The image field only has a link to the folder and image as in images/image1.jpg including size.

The thumbnail I want to display on a master display page is in the database using varchar and with a link as images/image1.jpg

When someone wants to view the master page they click on a link and everything that has been input shows from the database. At least everything but the image.  Right now it just shows images/image1.jpg

I don't know how to call the images from the database.

Thanks for the help and any information.

This topic has been closed for replies.
Correct answer

I tried this and will post the code to be sure but I still see the thumbnail image holder with the question mark.

Here is what I have in the database under thumbnail: images/bagsall/thumbs/bag13.jpg

This is a part of the code where I put in the code who wrote for me to try.

<td><?php echo $row_rsProducts['packaging']; ?>  </td>
      <td><?php echo $row_rsProducts['materials']; ?>  </td>
      <td><?php echo $row_rsProducts['serial_number']; ?>  </td>
      <td><?php echo $row_rsProducts['size']; ?>  </td>
      <td><img src="images/bagsall/thumbs/<?php echo $row_rsProducts['thumbnail'];?>" /> </td>
</td>

I wonder if what I've written in the database is incorrect somehow.

Thanks


conch,

Check the database entry, and you also might have one too many </td> tags...

Also, check to see if your images folder is in the root directory, as an incorrect path can complicate things.

If this site is on a remote server, feel free to send me the link, either here or via email: wordman@g490.com

Also, if you have a screenshot, that would be helpful.

Hang in there!

Cheers,

wordman

1 reply

April 13, 2010

Although it's not 'illegal' to put images or image thumbs in a database, it is strongly recommended NOT to store images/thumbs in a DB because it can seriously drag down the performance of the DB.

If you know how to call an image with information from your DB, you can do it with the thumbnaail image as well. The process is identical.

If you don't already have it, buy David Powers' book, 'PHP Solutions' as soon as you can. David's book walks you through basics of php and MySQL, the end result being a dynamic photo gallery. He cautions against storing anything in a DB that is not text or numbers, and it makes sense. VARCHAR isn't the correct column type, you would actually want one of the BLOB types. However, as David says in his book:

"Storing binary data, such as images, isn't a good idea. It bloats your database, and you can't display images directly from a database. However, the following column types are designed for binary data:

TINYBLOB:up to 255 bytes

BLOB: up to 64KB

MEDIUMBLOB: Up to 16MB

LONGBLOB: Up to 4GB"

I know what you are wantimg to do, because I am also developing an online gallery, so I feel your pain with a hitch such as this. The difference is, although I use Dreamweaver, I hand code everything. I use DW for more basic functions such as previewing and whatnot. With a little more info from you, I might be able to help, specifically some code, or a link to the gallery if it is on a remote server.

Be happy to help you any way I can.

Sincerely,

wordman

Participating Frequently
April 13, 2010

Thanks for the reply. I don't plan to store the images in the database but simply use the database to call them from a folder on the remote server.

Here is the basic code:

<?php do { ?>
    <tr>
      <td><a href="detailpage_web.php?recordID=<?php echo $row_rsProducts['product_id']; ?>"> <?php echo $row_rsProducts['product_id']; ?>  </a></td>
      <td><?php echo $row_rsProducts['product_type']; ?>  </td>
      <td><?php echo $row_rsProducts['product_name']; ?>  </td>
      <td><?php echo $row_rsProducts['price']; ?>  </td>
      <td><?php echo $row_rsProducts['packaging']; ?>  </td>
      <td><?php echo $row_rsProducts['materials']; ?>  </td>
      <td><?php echo $row_rsProducts['serial_number']; ?>  </td>
      <td><?php echo $row_rsProducts['size']; ?>  </td>
      <td><?php echo $row_rsProducts['thumbnail'];
?>

Where the last line is I want to have that get the image from the database table called thumbnail and post it on a display page. In the thumbnail cell i have a link to images/image1.jpg and have also tried using an http:// link but I don't get the image. I know there is a way to do this and if I wasn't out of the country I would buy that book immediately but have to rely on the kindness of the community for the moment. I'm new to this so it makes it a bit difficult.

Thanks for your help. Hopefully this is enough info to go on but I can supply more if needed.

Participating Frequently
April 13, 2010

conch,

I think you used the code in the previous post which was wrong, I screwed it up.

Replace this: <td><?php echo $row_rsProducts['thumbnail'];  </td>

With  this: <td><img src="folder/folder/<?php echo $row_rsProducts['thumbnail'];?>" /> </td>

To clarify, the DB doesn't read anything. It's just a place for information, like a great big book. The query is what actually does the reading. That's what makes them so cool, you can read the DB in many different ways to present your data in many different ways. I mention this for clarity.

What is happening in the above code is that everything between the <?php ... ?> tags is displaying the result of your query.

Please check your code against this: <td><img src="folder/folder/<?php  echo    $row_rsProducts['thumbnail'];?>" /> </td>

I apologise for the screw up, I did in fact write the code incorrectly the very first time. Stick to what is here, and it should do the trick.

As for patience, you are absolutely welcome. I know EXACTLY how you feel, and I was able to get some fantastic help here in Adobe's forums. We'll get you through this!

Sincerely,

wordman


I tried this and will post the code to be sure but I still see the thumbnail image holder with the question mark.

Here is what I have in the database under thumbnail: images/bagsall/thumbs/bag13.jpg

This is a part of the code where I put in the code who wrote for me to try.

<td><?php echo $row_rsProducts['packaging']; ?>  </td>
      <td><?php echo $row_rsProducts['materials']; ?>  </td>
      <td><?php echo $row_rsProducts['serial_number']; ?>  </td>
      <td><?php echo $row_rsProducts['size']; ?>  </td>
      <td><img src="images/bagsall/thumbs/<?php echo $row_rsProducts['thumbnail'];?>" /> </td>
</td>

I wonder if what I've written in the database is incorrect somehow.

Thanks