Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

Can someone help with how to get image

New Here ,
Apr 13, 2010 Apr 13, 2010

Copy link to clipboard

Copied

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.

TOPICS
Server side applications

Views

567
Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 13, 2010 Apr 13, 2010

Copy link to clipboard

Copied

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

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 13, 2010 Apr 13, 2010

Copy link to clipboard

Copied

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.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 13, 2010 Apr 13, 2010

Copy link to clipboard

Copied

conch,

The reason I mentioned storing images in a DB, I thought I read where you stored the actual thumbnail in the DB. If that is not the case, you're fine.

David is British, as is his publisher, Friends of ED (http://www.friendsofed.com/) Although his books are vaailable through Amazon, you can also order from the publisher, FYI. the website also has a forum where David participates (and he also actively participates here as well).

Okay, now on with the problem.

If I understand your meaning, what you need to do is add <img src=/folder/folder/<?php  echo $row_rsProducts['thumbnail'];?> to show the thumbnail. As it stands, I'm guessing that the last line is displaying the value for 'thumbnail' as opposed to the image you want.

Please let me know if I'm on the right track. My head is stretched out from long days of similar work, so I want to be certain I have your point.

Cheers,

wordman

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 13, 2010 Apr 13, 2010

Copy link to clipboard

Copied

I will try this and let you know but first a question to make sure I know where this is going. Does <img src=/folder/folder/<?php  echo  $row_rsProducts['thumbnail'];?> come after the size column. also where does img src actually go?

Right now I have this: <td><?php echo $row_rsProducts['size']; ?>  </td>
      <td><?php echo $row_rsProducts['thumbnail'];
     
?>

does the <img src= go before the ?php echo $row_reProducts? Just a bit confused.

thanks

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 13, 2010 Apr 13, 2010

Copy link to clipboard

Copied

conch,

I know, this stuff can be insanely confusing at the start.

I left out a few characters from the img src description in the last post, this is the correct code:

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

Apply the code exactly as shown  if you want  to show the image thumbnail.

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

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

I'm assuming that when you run your page as is now, it just returns the filename of the thumbnail, or whatever is in the DB under $row_rsProducts['thumbnail'], is that correct?

When you ask where the img src goes, do you mean the actual path where the image lies?

For the path, you would substitute: /folder/folder/ for whatever the path is to your folder containing the actual thumbnail image.

Please let me know how you do!

Sincerely,

wordman

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 13, 2010 Apr 13, 2010

Copy link to clipboard

Copied

Yes it is very confusing. Now when I add this in I get a question mark followed by ?>

Is it possible that the database isn't reading the img src folder?

When I ran the file before it just read the name of the thumbnail and image folder in the table, the way I had written it in. Now it shows a img box with a question mark followed by the actual ?>

thanks for being patient. I know I'm missing something crucial yet probably simple

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 13, 2010 Apr 13, 2010

Copy link to clipboard

Copied

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

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 13, 2010 Apr 13, 2010

Copy link to clipboard

Copied

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

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 13, 2010 Apr 13, 2010

Copy link to clipboard

Copied

LATEST

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

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines