Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Display image pointed to in database 1

Status
Not open for further replies.

tomhughes

Vendor
Joined
Aug 8, 2001
Messages
233
Location
US
Does anyone know how to display an image in a frame in a web page that is accessed through a Recordset in Microsoft Access. I tried to use the Hyperlink property in the cell in Access, but the image it was pointing to did not show in the web page.
 
Hi Tom,

Yea, you sure can, I do it on a few different websites.

Lets say you have a table called tblInfo and in that table you have a field named Picture. In the field you may have for one record lets say 12345.jpg

Now on your asp page, your recordset should show the picture field as an option. Your link would look like this


<img src=&quot;
With that you can see it will pull the picture from an images directory.
 
schase - How do I link to the image in the field in the data base. Right now I am hyperlinked to it, but it does not work.
 
ok do not do hyperlink

You also do not need to set up a link

Tell me the following,

recordset name
Table Name (where the other info is along with the picture field)
Name of the picture field within the table.

Make sure that in the field for pictures you have the image names, like 12345.jpg

 
Recordset name = &quot;Recordset1&quot;
Table Name = &quot;Table1&quot;
Name of Picture Field = &quot;Frame2&quot;

My question is - What goes in the field in the data base that points to the picture???
 
ok, make sure the table cell is empty where you want the picture field to display - click in it, and in the code part you should see the curser between TD codes.

Cut and paste this.

<img src=&quot;images/<%=(Recordset1.Fields.Item(&quot;Frame2&quot;).Value)%>&quot;>

Change images/ to the directory name where the images are stored.

In the field Frame2 you want the picture name.
for example say you have a .jpg picture called 122345

you would put in that field
122345.jpg

 
schase - Lets start over-

1) I am trying to display a picture in a web page
2) The web page is linked to a recordset
3) The recordset points to a Microsoft Data Base
3) In the field in the Microsoft Access data base is some kind of a link to the picture. Since you can't put a picture in a Microsoft Access data base, you have to put some kind of a link to that picture.
The part that is not working is the link to the picture from the Microsoft Data Base. If I just put the name of the picture in the Field in the data base, then all I have is text. How do I link the field in the Microsoft Data Base to the Picture???
 
putting just text in the database is perfect

that is the easiest method to do what you want.

The above code I gave you takes that text (for example 12345.jpg) and makes the link to the picture for you

This
<img src=&quot;images/<%=(Recordset1.Fields.Item(&quot;Frame2&quot;).Value)%>&quot;>

Turns into this for the browser.
<img src=&quot;images/12345.jpg&quot;>

It takes the text - in our case the pictures name, and inserts it in the source code for the image. And will do it for each and every record.

See how you have <%=(Recordset1.Fields.Item(&quot;Frame2&quot;).Value)%> stuck inbetween the img src code?

That recordset will pull from the database, the name of your image, and complete the image link.

Just straight text in the database field.

 
missing one thing, afer you have Value)%> make sure it is Value)%>&quot;>


It does go inbetween the <TD> and </TD> code in the table where you want the picture placed.

make sure the code does not have any ;

Make sure the field in the database is called &quot;Frame2&quot;, check caps also.

Make sure the image is in the images directory you are pointing too.

If all is correct,

Give me a picture name so I can test the url to the picture
 
schase - Thanks for being patient with me.
I see now how all the links work.
When I put the extra &quot;> in the code at the end of the string it shows up on the page as text. Also you said not to put any semicolons in the text - This is how ny code looks, and if i try to get rid of the semicolon, it gives me a markup errror.

<img src=&quot;Images/<;%=(Recordset1.Fields.Item(&quot;Frame2&quot;).Value)% >&quot;>
 
schase - Well Finally - It works - Thanks for all your help - I really appreciate it. I had to clean up spaces in the code.
 
Hi Tom,

You bet, and my apologies for not responding earlier - had a customer come in.

As an afternote,

That little link part works great for other items too. You can even do the alt tags for pictures by just having another field in your database.

Regular URL Links - same thing.

 
schase - Do you know how to make a link to text files? &quot;img src&quot; doesn't work for text?

Also what did you mean by this statement?

You can even do the alt tags for pictures by just having another field in your database.

Again, I want to thank you for helping me out.
 
Hi Tom,

Sure, 2nd part first.

As long as you make a field for alt tags, like where you have your picture field named Frame2, you can also make a field say &quot;alttext&quot; - note there are some titles you need to stay away from, that is why I get into the habit of naming it slightly different - my tables all start with tbl

ok, so we have Frame2, with a the name of a picture 12345.jpg in it, and next to frame2 you have a field called &quot;alttext&quot;, in that you put the text &quot;Picture of me in front of my house&quot; (or whatever alt you want)

Then like you did with the img src - except adding another field

<img src=&quot;Images/<;%=(Recordset1.Fields.Item(&quot;Frame2&quot;).Value)%>&quot; alt=&quot;<;%=(Recordset1.Fields.Item(&quot;alttext&quot;).Value)%>&quot;>

Then when you look at the web page, you will see the picture - run your mouse over it and the text box will show.
Pretty nifty thing.

Ok part 1

Instead of img src alter it to <a href=&quot;<%=(Recordset1.Fields.Item(&quot;FIELDNAME&quot;).Value)%>&quot;>Any link text you want</a>

 
Awsome - But can I simply put the name of a text file in the Field, and without any interaction from the user (like passing a mouse over the picture) just show up the text. I am using two tables, the one on the left has text, the one on the right has a picture. Maybe I have to just put the text in the Field, instead of the name of the text.
 
sure, but don't do the alt then - that only works with mouse over. - unless you want both.

you can put a description for one cell in the table
and do a field in the database for it then
Just drag the field name into the cell from your recordset.
 
uhhh I forgot - it would be easiest if you put the text in the field inside the database rather than try to link a .txt file
 
schase - Is there any way I can just put the name of the text file in the field, insted of the whole text???
 
well I've never tried this

but

hmmmmm

ok, do you have one text file or one for each picture? and how are they named?

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top