PDA

View Full Version : images question


gcapp
11-14-2002, 05:36 PM
Can this be done?

I have one asp page that I call department-top.asp and in that page I would like to have an image appear based on the department. There are 20 departments. Is there some sort of asp code which can load the image based on a number or category??

I have a database table where I have each department have an ID number.

If someone knows of any code that I can do this with, I would appreciate it.

Gary

marko1103
11-14-2002, 07:22 PM
If the deptID is passed in the querystring to the page, then you can call upon that variable to determine which picture is loaded using a simple if,then,elseif statement. OR you can store the imagepath in the database itself for each department and call upon it when you load the department page.
Example:
I load the following page: http://www.whatever.com/dept-top.asp?deptid=1

_________CODE HERE_________
Create connection to Database (I use ADO)
Open a recordset to your departments table using an SQL statement that includes the field where the imagepath is based on the querystring.
Example:
sql = "select * from departments where deptid = " & request.querystring("deptid")
let's say that the field where the imagepath is, is called "deptimg" and your recordset is called "RS"

response.write "<img source ='" & rs("deptimg") & "'"

There are other ways to do this. If you need help, email me at marko1103@hotmail.com

Peace Out!

whammy
11-14-2002, 11:44 PM
I'd probably go with the database way, as it makes for cleaner code. :)