Print Page | Close Window

Images in a databae

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Database Discussion
Forum Description: Discussion and chat on database related topics.
URL: https://forums.webwiz.net/forum_posts.asp?TID=2344
Printed Date: 28 March 2026 at 3:11pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Images in a databae
Posted By: 288enzo
Subject: Images in a databae
Date Posted: 01 May 2003 at 11:45am

I am very new at this and am not even sure how to explain this.

I have a database that has the ID number that never duplicates.

I have no problem accessing the database and viewing information.

What it is that I would like to do is the following:

I have a directory named /images

And in the directory are jpeg’s that are numbered.  The numbers correspond with the database ID numbers.

How can I view my database and on the same line as ID 50 view the file 50.jpg?

Does this make sense?

Thanks for the help.




Replies:
Posted By: ultramods
Date Posted: 01 May 2003 at 1:22pm

sql= "select ID from table where ID= 50"

<% response.write("<img src=""" & "picFolder/" & rs("ID") & ".jpg""" &  "width='300' height='200' align='center' >")%>



Posted By: 288enzo
Date Posted: 01 May 2003 at 2:13pm

I got that, I guess I didn't explain well enough.

When you view database.asp you will get a table that lists all data in the database.  The first column in a generic image.  What I would like to do is:

click on the generic image and have the true image open in another window.  the true image's file name would be the "ID number".jpg

meaning on row 45 would could click on the generic image and have image 45.jpg or whatever the id might be for rouw 45 open in a new window.

I know that this is much more complicated, that is why I am here asking questions.

Thanks for the quick reply.



Posted By: ultramods
Date Posted: 01 May 2003 at 2:38pm

Is this what you mean.

----------------------page 1------------------------

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript">
<!--
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
//-->
</script>
</head>

<body bgcolor="#FFFFFF" text="#000000">
<%
'Execute your sql statement.

while not rs.EOF
RESPONSE.WRITE("<img src=""generic.jpg"" width=""200"" height=""150"" onClick=""MM_openBrWindow('specificpic.asp?picID=" & rs("ID") & "','Picture','width=200,height=200')""> ")

rs.movenext
wend
%>
</body>
</html>
----------------------end page 1------------------------

----------------------pop-up page------------------------

<%
OPTION EXPLICIT

Dim pic

pic = Trim(Mid(Request.QueryString("picID"), 1, 8))
%>

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body bgcolor="#FFFFFF" text="#000000">

<% response.write("<img src=""" & "picFolder/" & pic & ".jpg""" &  "width='300' height='200' align='center' >")%>

</body>
</html>



Posted By: 288enzo
Date Posted: 01 May 2003 at 2:46pm

Damn your fast, I have no idea how you did that so quickly and precise.  Your a genius.

Thanks much.  You should have more than 2 stars under your name!!!



Posted By: 288enzo
Date Posted: 02 May 2003 at 12:07am
Ok, I just go around to trying it out and came up with the following problem. A pop up window does not open, actually nothing opens.

The following is my page:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>OC Beach Rentals</title></head>
<script language="JavaScript">
<!--
function MM_openBrWindow(theURL,winName,features) { //v2.0
     window.open(theURL,winName,features);
     }
//-->
</script>
</head>
<body>
<%
Dim adoCon                
Dim rsListings          
Dim strSQL               
Set adoCon = Server.CreateObject("ADODB.Connection")
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)};pwd=; DBQ=" & Server.MapPath("/database/ocbeachrentals.mdb")
Set rsListings = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT tblListings.ID, tblListings.Location, tblListings.Rent, tblListings.Image FROM tblListings;"
rsListings.Open strSQL, adoCon
Do While not rsListings.EOF
%>     
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="310" id="AutoNumber1" height="20">
<tr><td width="30" align="center" height="20">
<%     Response.Write ("<img src=""..\images\camera.jpg"" width=""30"" height=""20"" onClick=""MM_openBrWindow('pic.asp?picID=" & rsListings("ID")& "','Picture',width=200,height=200')"">")%>
</td>
<td width="30" align="center" height="20">
<%     Response.Write ("<a href=""delete_entry.asp?ID=" & rsListings("ID") & """>")
Response.Write (rsListings("ID"))
Response.Write ("</a") %> </td>
<td width="150" colspan="2" height="20">
<%     Response.Write (rsListings("Location")) %>  </td>
<td width="100" align="center" height="20">
<%     Response.Write (rsListings("Rent")) %>  </td>
<%
rsListings.MoveNext
Loop
rsListings.Close
Set rsListings = Nothing
Set adoCon = Nothing
%>
</table>
</body>
</html>

And the following is the pop up:

<%
OPTION EXPLICIT
Dim pic
pic = Trim(Mid(Request.Query.String("picID"), 1, 8))
%>
<html>
<head>
<title>Pic</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<% response.write("img src=""" & "/images/" & pic & ".jpg""" & "width='300'height='200'align='center'>")%>
</body>
</html>

Any ideas?

Thanks again, you have been a great help. I'm actually beginning to understand some of this.


Posted By: ultramods
Date Posted: 02 May 2003 at 4:50am

Change the parts in bold, on you main page.

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>OC Beach Rentals</title></head> ---remove this
<script language="JavaScript">
<!--
function MM_openBrWindow(theURL,winName,features) { //v2.0
     window.open(theURL,winName,features);
     }
//-->
</script>
</head>
<body>
.........................................

onClick=""MM_openBrWindow('pic.asp?picID=" & rsListings("ID")& "','Picture',  '   width=200,height=200')"">")%>



Posted By: 288enzo
Date Posted: 02 May 2003 at 9:14am

Great - the pop up pops up.  In the pop up window I get the following error:

Microsoft VBScript runtime error '800a01b6'

Object doesn't support this property or method: 'Request.Query'

/guest/pic.asp, line 4

This is my pop up:

<%
OPTION EXPLICIT
Dim pic
pic = Trim(Mid(Request.Query.String("picID"), 1, 8))
%>
<html>
<head>
<title>Pic</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<% response.write("img src=""" & "../images/" & pic & ".jpg""" & "width='300'height='200'align='center'>")%>
</body>
</html>

Thanks again.  Are you really from Scotland?



Posted By: 288enzo
Date Posted: 02 May 2003 at 4:22pm

I think the error is in the following line:

<% response.write("img src=""" & "../images/" & pic & ".jpg""" & "width='300'height='200'align='center'>")%>

I think I need to add something so that the pop up doesn't just look for pic.jpg but for the specific pic(ID).jpg.  I don't think it is doing that.  Can you tell me what I need to change or add so that it will look for the specific jpg?

Thanks for all the help.



Posted By: 288enzo
Date Posted: 02 May 2003 at 4:36pm
Nevermind about my last post, I don't think I know what it is I am talking about.  I still am having a problem with the pop up showing an image.


Posted By: ultramods
Date Posted: 02 May 2003 at 8:18pm

Use pic = Trim(Mid(Request.QueryString("picID"), 1, 8))

And not pic = Trim(Mid(Request.Query.String("picID"), 1, 8))



Posted By: 288enzo
Date Posted: 14 May 2003 at 9:28pm
Thanks, that did it. Everything now works correctly.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net