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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Database picture

Status
Not open for further replies.

Ragol1

Programmer
Oct 25, 2001
315
US
I have a databse that users can search and I would like to be able to display a picture in one of the fields right now is just displays text.
Can someone help please..
 
Hi Ragol,

This works for me. I have an Access database with a field marked Pictures where I will put like 12345.jpg as the data text. In the ASP I have the following.

img src="
You do not have to have it with http:// first, I do because I pull from a separate domain. you can simply have img src="../images/ instead.

Hope this works.
 
whooops, sorry get rid of the ; and add %>"> after value.
 
I use this code to get info from database where would i add picture link or what would i type in database
the filed is Pic
Dim SqlJunk


Set dbGlobalWeb = Server.CreateObject("ADODB.Connection")
dbGlobalWeb.Open("Members")

SqlJunk = "SELECT * FROM Members"

If Request.Form("TypeSearch") = "UserID" Then
SqlJunk = SqlJunk & " WHERE UserID LIKE '%" & Request.Form("DaInBox") & "%'"
End If

If Request.Form("TypeSearch") = "Pic" Then
SqlJunk = SqlJunk & " WHERE Pic LIKE '%" & _
Request.Form("DaInBox") & "%'"
End If

Set rsGlobalWeb = Server.CreateObject("ADODB.Recordset")
rsGlobalWeb.Open SqlJunk, dbGlobalWeb, 3
%>
<%
If rsGlobalWeb.BOF and rsGlobalWeb.EOF Then%>

<%
Do While Not rsGlobalWeb.EOF
%>
<tr bgcolor=&quot;#CCCCCC&quot;>
<td width=&quot;15%&quot;><font color=&quot;#000000&quot;><%=rsGlobalWeb(&quot;UserID&quot;)%></font></td>
<td width=&quot;14%&quot;><font color=&quot;#000000&quot;><%=rsGlobalWeb(&quot;Pic&quot;)%></font></td>

<% rsGlobalWeb.MoveNext
Loop
%>
 
Are you using Access or SQL, etc.?

Can you post the link to the specific page too please.
 
im using access2000 you cannot get to the page as its in a members section
I already use this to display the text can i not point the database to a picture
Sorry if im confusing the matter I just want a little gif to appear instead of the text.

<td width=&quot;14%&quot;><font color=&quot;#000000&quot;><%=rsGlobalWeb(&quot;Pic&quot;)%></font></td>
 
Okay, I use Access2000 as well.

In Access 2000, for example I have under field Pictures. The data is 12345.jpg (just typed in the access field).

Now on the asp side of things, you combine html with the asp.

< img src=&quot;
What this does, is first says ok, display a image from the location normally you would put a picture file name here, but we put in the asp of
< %=(rsInventory.Fields.Item(&quot;Picture&quot;).Value)%>&quot;>

In your case, lets say you named a picture test.jpg and your access field name for pictures is &quot;Pic&quot; and the test.jpg is located in your images directory.

Your source code would then be:
< img src=&quot;../images/<%=(rsGlobalWeb.Fields.Item(&quot;Pic&quot;).Value)%>&quot;>

(remove the space between the first < and img)
 
Yes thank you very much just got it working my only problem now is that i need to display ALT tags when i hang over each image
Any ideas
 
I have tried to use fireworks to set alt tags in the pictures and changed the .gif to .png in the database but it still doesnt display the tag.

If i view the pictures from its location it displays the tag just not though the database ..
Any ideas.
 
Okay give this a shot. Note where the Alt was placed. Again, remove the space between the very first < and img .



< img src=&quot;../images/<%=(rsGlobalWeb.Fields.Item(&quot;Pic&quot;).Value)%>&quot; alt=&quot;Picturetexthere&quot;>


The above will work if you have one specific ALT tag for every picture. If you would like the Alt to change with the picture then you can have a separate field in your database, say you call it ALT. you would be something like the following code.


< img src=&quot;../images/<%=(rsGlobalWeb.Fields.Item(&quot;Pic&quot;).Value)%>&quot; alt=&quot;<%=(rsGlobalWeb.Fields.Item(&quot;ALT&quot;).Value)%>&quot;>


Please note, I have not tested the last code, if you use it and have problems, let me know. And Please let me know when all is well.
 
ok I will give it a shot
need to change quite a bit of stuff so it will be after lunch
Thanks
 
your the man worked first time
Thank you so much

On a different note I have some code that someone wrote for me which is not quite working right and he doesnt seem to know whats wrong.
Its pretty complicated &quot;well for me at least&quot;
What happens is on my site people log in and go to a members section .let me go back When they join all their info gets put into this database and it all works ok .
At which point they can now search the database for other members and look at some of that members info..
Well I want the members to be able to change some of their info but obviously they should only be able to change thier info.
So when they log in i create a session and this is where the guys code is supposed to work but doesnt.

would you be interested in taking a look at it ?
It consists of 4 pages and the database..

I understand if you dont want to.
Thanks for all your help
 
sure, would be alot more helpful if you can email it to me though. schase02@elp.rr.com I can take a look later on tonight.
 
Ok emailed it thanks let me know if you need anything else.

Of to lunch now be back in an hour
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top