Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 11th, 2003, 02:26 PM
Friend of Wrox
 
Join Date: Aug 2003
Posts: 166
Thanks: 0
Thanked 0 Times in 0 Posts
Default Show Images from Database

<input type=text value="<%if Request.QueryString("ID") > 0 then%><%=RS("PicID")%><%end if%>" size=10 name="PicID">

I have a frame with all the items in the Table. When you click on an item it shows the information in the text box's in the right frame. With the above code. I am wondering how to take that info and view the photo that has been selected. With a preview, or something. I need to see the photo instead of just the name

__________________
-----------------------------------------------------------
\"Don\'t follow someone who\'s not going anywhere\" John Mason
 
Old December 11th, 2003, 03:48 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

How is your photo stored? If it's in the database as binary data, you'll need to create an ASP page that returns that data. The page needs to do nothing more than select the data from the database, set the response content type (image/gif,image/jpeg, etc), and do a Response.BinaryWrite of the data. The you can access the page like this:

image.asp?ID=1234

If you want the image in a page, you would draw a regular img tag, and make the src that asp URL:

<img src="image.asp?ID=1234">

Peter
------------------------------------------------------
Work smarter, not harder.
 
Old December 16th, 2003, 02:20 PM
Friend of Wrox
 
Join Date: Aug 2003
Posts: 166
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The photo is just stored as a name in the database that points to the folder, where it is. I am just selecting everything from the table. I am using the Request.QueryString to fill my text boxes when the link of the name of the photo is clicked. But I also want to show the photo as well. So can I use the Request.QueryString with an img src tag or some variation of it?


 
Old December 16th, 2003, 03:01 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
Default

if you just have the name of the file you can use this:

<img src=images/" & rS("myPics") & ".gif height=35 width=40 border=0 />

only append the .gif if that's not a part of the name of the image.

 
Old December 16th, 2003, 03:20 PM
Friend of Wrox
 
Join Date: Aug 2003
Posts: 166
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for your help, but I can't get it too work, I just get a broken image

<img src="piclibrary/" & RS("Url") & ".gif height=35 width=40 border="0">

 
Old December 16th, 2003, 03:39 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
Default

if you look at the code (view code) once the page is loaded find the first img and tell me what it says for the source. It should read <img src="piclibrary/picname.gif" height=35 width=40 border=0 />

Also check your -->"<-- marks.

<img src="piclibrary/" & RS("Url") & ".gif height=35 width=40 border="0">

remove the red ones. you must escape the " marks with quotation marks but if you don't know what you're doing it gets confusing. Once you get it running right I'll show you how to escape the quotation marks.
 
Old December 16th, 2003, 03:49 PM
Friend of Wrox
 
Join Date: Aug 2003
Posts: 166
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I don't have the images anywhere on the page. Just a list of the file names, as links. When I click on the link or filename it fills the text boxes with the rest of the info for that photo, I want to use the tag you are helping me with to just show the image of the link that was clicked. So the images aren't being loaded anywhere else. When I remove the red tags from my code and I click on the filename I get this
<img src=piclibrary/" & RS("Url") & ".gif border=0>

instead of the image(the code shows on the page)
So there is no source
I just want to use the name from the database "Url" to link to the images in /piclibrary and be displayed on screen

 
Old December 16th, 2003, 03:54 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

So far in this thread you haven't specified if you are generating the image tag in ASP (and you need to fill in the image name with string concatenation) or if it's in HTML (and you need to pop the image name in with an ASP snippet. I'm assuming you are using the latter, so this is probably what you are looking for. :

<img src="piclibrary/<%=RS("Url")%>.gif" border="0">

Peter
------------------------------------------------------
Work smarter, not harder.
 
Old December 16th, 2003, 04:06 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
Default

your link to the view page will have to be like Peter had wrote... image.asp?id=<% rs("id") %>

the rs("id") should be the id or the primary key where the picture name is located. Then you want to request.querystring("id") on the next page and pass the variable in the strSQL statement's WHERE clause.

myPicID = request.querystring("id")

strSQL = "SELECT images FROM mydatabaseTable WHERE id= '" & myPicId& "';"

Then add <img src=piclibrary/" & RS("image") & ".gif border=0>

**Also what is the value in the database for the Url column?

 
Old December 16th, 2003, 04:17 PM
Friend of Wrox
 
Join Date: Aug 2003
Posts: 166
Thanks: 0
Thanked 0 Times in 0 Posts
Default

<a HREF="main.asp?ID=<%=RS(0)%>" TARGET="right">

Here is my link code.
I don't want to touch this code because I need the text boxes to be filled. But all I get is a broken image.
The "url" column just holds the image name like logo.gif
I tired this

<%if Request.QueryString("ID") > 0 then%><img src="piclibrary/<%=RS("Url")%>.gif" border="0"><%end if%>


if Request.QueryString("ID") > 0 then
    SQLStr="SELECT * FROM ORLibrary WHERE PicID=" & Request.QueryString("ID")
    Set RS=Server.CreateObject("ADODB.Recordset")
    RS.Open SQLStr,Application("DBConn"),adOpenKeyset,adLockPe ssimistic,adCmdText
    Session("yestoadd") = "No"
end if

this is my sql statement to get all the fields from the table





Similar Threads
Thread Thread Starter Forum Replies Last Post
Thumbnail images do not show up svgiles BOOK: Professional CodeIgniter ISBN: 978-0-470-28245-8 2 September 2nd, 2008 01:00 PM
Load Images from and Save Images to a Database cyndie VB.NET 2 August 17th, 2008 06:42 AM
show html email with images dr_huda Pro PHP 1 April 9th, 2006 01:07 PM
how I can show and upload a images Alexds ASP.NET 1.x and 2.0 Application Design 2 May 19th, 2005 04:14 PM
Stored Procedure to show Images desireemm SQL Server 2000 0 April 25th, 2005 06:03 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.