Quick,example,Creating,Online,Photo,Album,usi
Quick Search for:  in language:    
Quick,example,Creating,Online,Photo,Album,usi
   Code/Articles » |  Newest/Best » |  Community » |  Jobs » |  Other » |  Goto » | 
CategoriesSearch Newest CodeCoding ContestCode of the DayAsk A ProJobsUpload
ASP/ VbScript Stats

 Code: 118,709 lines
 Jobs: 148 postings

 
Sponsored by:

 

You are in:

 
Login


 

 


Latest Code Ticker for ASP/ VbScript.
Click here to see a screenshot of this code!Create Time List Selection
By Chris on 6/12

(Screen Shot)

Getting a random record from a table
By Serkan YOGURAN on 6/11


cool circle and line drawer
By john sheridan on 6/10


Click here to see a screenshot of this code!A Site Manager with Free Upload Functions (without payable components)
By Francisco J Riquelme on 6/10

(Screen Shot)

Simple Calculator
By Alistair Rodrigues on 6/9


Nutty Password
By jason mulryan on 6/9


Enviar email HTML ( send an email html )
By Javi P. D. on 6/9


Banner (rotacion de banners)
By Javi P. D. on 6/9


Paginar ( Paging )
By Javi P. D. on 6/9


Click here to put this ticker on your site!


Add this ticker to your desktop!


Daily Code Email
To join the 'Code of the Day' Mailing List click here!





Affiliate Sites



 
 
   

Creating an Online Photo Album

Print
Email
 

Submitted on: 7/21/2000 11:03:22 AM
By: Christopher Miller  
Level: Intermediate
User Rating: By 1 Users
Compatibility:ASP (Active Server Pages), HTML

Users have accessed this article 15061 times.
 
 
     Quick example of Creating an Online Photo Album using a database back-end.

 
 
Terms of Agreement:   
By using this article, you agree to the following terms...   
1) You may use this article in your own programs (and may compile it into a program and distribute it in compiled format for langauges that allow it) freely and with no charge.   
2) You MAY NOT redistribute this article (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
3) You may link to this article from another website, but ONLY if it is not wrapped in a frame. 
4) You will abide by any additional copyright restrictions which the author may have placed in the article or article's description.
Creating an Online Photo Album
by Ritchie Macapinlac

Useful Links

·         A working copy of this application.(http://www.boogienet.com/photoalbum)

·         JavaScript Tutorial (http://hotwired.lycos.com/webmonkey/programming/javascript/tutorials/tutorial1.html)

The Application Description

The whole backbone of the application is the database, which maintains a set of links to images and the comments to the images. The database will have 4 fields: pic_id, thumbnail, pic_url, and comment. Each record will represent 1 picture that the database maintains. Each set of pictures has 2 physical files (thumbnail and the actual picture url).

There are 2 asp pages to the whole application. One page, will be the index of the pictures and the second will display the actual picture. We use javascript to open the actual picture up from the index page, passing it the actual address of the picture.

The Database

The database only maintains a set of links and does NOT store images in the fields themselves.  There are 4 fields in the database:

1.       Pic_id, is the unique identifier of the picture and how the pictures are ordered on the index page. (number, also the primary key)

2.       The thumbnail field is the url of the thumbnail of the picture in the index page. (text)

3.       The pic_url page maintains the links to the actual picture. This will be passed from the index page to the display page. (text)

4.       The pic_description, is used to have a comment associated with every picture. (memo)

The Index Page

The index page is a combination server-side asp (to process the database) and client-side javascript (to pass the url to the display page).

The code of the page looks like this:

 

<html>

<head>

            <title>Album Index Page</title>

<script language=”JavaScript”>

function OpenPic(url){

            //format url of the picture

            var newwindow = "pic.asp?pic_url=" + escape(pic_url);

            //properties of the new window

            var window_properties = "title=false,width=400,height=400";

            //open the window

            var PicWindow = window.open(newwindow,"Album",window_properties);

};

</script>

</head>

 

<body>

 

<%

Dim dbConnection, rsRecordSet, strSQL

 

StrSQL = “SELECT * FROM tblAlbum ORDER BY pic_id ASC”

 

Set dbConnection = Server.CreateObject(“ADODB.Connection”)

Set rsRecordSet = Server.CreateObject(“ADODB.RecordSet”)

‘open the database with the connection string (dsn or dsn-less) - replace “connection_string with your database connection string

DbConnection.Open “connection_string”

RsReocrdSet.Open strSQL, dbConnection

If not(rsRecordSet.EOF and rsRecordSet.BOF) then

            RsRecordSet.MoveFirst

            While not rsRecordSet.EOF

%>

<a href=”javascript:OpenPic(‘<%Response.Write(rsRecordSet.Fields.Item(“pic_url”))%>’)”>

<img src=”<%Response.Write(rsRecordSet.Fields.Item(“thumbnail”))%>”></a>

<br>

<%Response.Write(rsRecordSet.Fields.Item(“pic_description”))%>

<br><br>

<%

                        RsRecordSet.MoveNext

            wend

End if

RsRecordSet.Close

DbConnection.Close

Set rsRecordSet = Nothing

Set dbConnection = Nothing

%>

</body>

</html>

 

Ok, simple databases query page, but here’s the cool part. In the “<a href” tag, it calls the javascript function to open the new window and pass the url to the display page.

The Display Page

The only thing the display page does is display a picture url. The picture url is passed through the querystring calling this page. Of course there are 2 ways to do this, one is javascript and the other of course is server-side vbscript. To keep things simple and consistent, we’ll learn the “easier” vbscript first.

 

<html>

<head>

            <title>Display Picture</title>

</head>

 

<body>

            <center>

            <img src=”<%Response.Write(Request.QueryString(“pic_url”))%>”>

            <br><br>

            <form>

            <input type=”Button” OnClick=”self.close();” value=”Close Window”>

            </form>

            </center>

           

</body>

</head>

</html>

 

That’s all there is to that page.


Other 3 submission(s) by this author

 

 
Report Bad Submission
Use this form to notify us if this entry should be deleted (i.e contains no code, is a virus, etc.).
Reason:
 
Your Vote!

What do you think of this article(in the Intermediate category)?
(The article with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor See Voting Log
 
Other User Comments
1/12/2001 11:31:35 PM:Pablo Gonzalez
Hey, I got a error in the JavaScript code, because it isn´t work, so I fixed it: On the line: var newwindow = "/pic.asp?pic_url=" + escape(pic_url). Change "escape(pic_url)" to "escape(url)" But It is a great work. It help me a lot
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
1/6/2002 7:39:54 PM:moon
This code is extremely buggy - There are at least 10 - 20 seemingly
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
1/6/2002 7:45:47 PM:moon
This code is extremely buggy - There are at least 10 - 20 seemingly "intentional" bugs. Why would the author sabotage his own work? Maybe because he doesn't want us to have a working album. If you don't believe me, please use his code and attempt to create a working ASP/album. Please try! I'm not sure how this code won "Code of the Month" - that sure doesn't say much for this website.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
Add Your Feedback!
Note:Not only will your feedback be posted, but an email will be sent to the code's author in your name.

NOTICE: The author of this article has been kind enough to share it with you.  If you have a criticism, please state it politely or it will be deleted.

For feedback not related to this particular article, please click here.
 
Name:
Comment:

 

Categories | Articles and Tutorials | Advanced Search | Recommended Reading | Upload | Newest Code | Code of the Month | Code of the Day | All Time Hall of Fame | Coding Contest | Search for a job | Post a Job | Ask a Pro Discussion Forum | Live Chat | Feedback | Customize | ASP/ VbScript Home | Site Home | Other Sites | About the Site | Feedback | Link to the Site | Awards | Advertising | Privacy

Copyright© 1997 by Exhedra Solutions, Inc. All Rights Reserved.  By using this site you agree to its Terms and Conditions.  Planet Source Code (tm) and the phrase "Dream It. Code It" (tm) are trademarks of Exhedra Solutions, Inc.