0

I have a website which has 3 image boxes within the header section. I've worked on writing some jQuery that will allow for my images to fade in and out, which works like so:

<script src="/Scripts/jquery-2.1.1.js" type="text/javascript"></script> 
 <script type="text/javascript">
    $(document).ready(function (){
        setTimeout(function (){
            $('#Image1').fadeOut('slow');                                   
        }, 3000);                           
    });

    var fadeBack = function () {
        setTimeout(function () {
            $('#Image1').fadeIn('slow');
        }, 6000);
    };

    fadeBack();
</script>        

However, each one of the boxes will have 7 photos that pass through it in slideshow fashion.

The main issue is that I've built a little SQL database in my project that contains the following:

Photo Database

And here are the 3 image boxes in the header:

Header Image Bar

My table is called tbl_Photos, and the database is called DetailPhotos.dbo. The table structure is setup as:

  • intPhotoID, int, Primary Key
  • strPhotoName, varchar(50)
  • imgPhoto, image

You can see my images like detail_1.jpg in the Images folder in the root of the site. I was told I could create a slideshow of the images from a database, but I don't know how to get the images "inside" of the database. How do I accomplish this? Will I have to create some special SQL to move photos from the Images folder to the database? And is it possible to populate the 3 boxes from the database with the images?

This is a new venture for me and I would like to lock this in mind, so I know for future use. Thanks.

1
  • the image column type does not mean an image as in say a jpg. It means binary data. If you really intend to use a DB, then you should probably use varbinary(max). But decide if you really want to store files in the DB. A DB is best for data & a filesystem is best for files. Would you be better storing the files on disk & storing the location in the DB? Commented Aug 24, 2014 at 23:49

1 Answer 1

2

I would suggest that instead of attempting to store an image in the db to store a filepath to that image in the db. Then you can get that filepath from the db and pass it in as the source for your image or images.

So maybe change your image attribute to say, img_path and place the relative file paths in this location.

Sign up to request clarification or add additional context in comments.

2 Comments

Sounds interesting. I take it that the datatype then becomes varchar as opposed to the binary type of image?
Yeah thats the right track :). Check out this article, I believe it has a good explanation outlined as well. revsys.com/blog/2012/may/01/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.