Hawkeye
04-07-2005, 09:52 AM
I need to display images that are located outside a DSN-less database connection in ASP. The old site was actually done in ASP.NET, but I want to do away with it as I am cheap.
At this point I can call up and display any and all of the database records. What I need is a way to combine the returned contents of a column with the path to the images and add on values for those that have multiple images.
For example: The database returns a value of say 9930120. The page should add that number to the path "say ...images/" add a value for + multiple images named with an a,b,c,d, e etc. and the file extention (.jpg) and then be able to display that/those image(s) in the table.
Here is the code:
<!-- #include file="connectionstring.asp" -->
<%
'variables
dim Conn, Connstring, Sql_Get, TheArray, Recordset
'database connection
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Provider = provider
Conn.ConnectionString = dbasepath
Conn.Open
'Sql statement
Sql_Get="SELECT * FROM table ORDER BY id"
Set Recordset = Conn.Execute(Sql_Get)
' get the recordset data in memory using getrows()
TheArray = RecordSet.Getrows
' Cleanup objects
Conn.Close
Set Conn = Nothing
Set RecordSet = Nothing
%>
<%
' start an HTML table to contain the results.
Response.write "<table border=1 width=500 cellpadding=3>"
' start the loop
For x = 0 to UBound(TheArray,2)
'format & write out the results
Response.write "<TR><TD><font size='1'>"
Response.Write "<b>Property Type</b> " & TheArray(16,x) & "<br>"
Response.Write "<b>#:</b> " & TheArray(1,x) & "<br>"
Response.Write "<b>Location:</b> " & TheArray(2,x) & " " & TheArray(10,x) & ", " & TheArray(11,x) & ", " & TheArray(14,x) & " County" & ", " & TheArray(12,x) & "<br>"
Response.Write "<b>ZipCode:</b> 0" & TheArray(3,x) & "<br>"
if InStr(UCase(TheArray(4,x)), "HTTP://") = 1 then TheArray(4,x) = "<a href='" & TheArray(4,x) & "'>" & TheArray(4,x) & "</a>"
Response.Write "<b>Link:</b> " & TheArray(4,x) & "<br>"
Response.Write "<b>List Price $:</b> " & TheArray(13,x) & "<br>"
Response.Write "</font></TD></TR>"
' next position
Next
' close table
Response.write "</TABLE>"
%>
The OLD site actually used ASP.NET and I don't know how this worked, but this appears to..
<a href='<%# databinder.eval(container.dataitem, "ML Number", "relistings.aspx?mls={0}")%>' target="relisting">
<IMG border="0" src='<%# checkPix(databinder.eval(container.dataitem, "ML Number"))%>' width="151" height="121"></a>
any help is welcome.
At this point I can call up and display any and all of the database records. What I need is a way to combine the returned contents of a column with the path to the images and add on values for those that have multiple images.
For example: The database returns a value of say 9930120. The page should add that number to the path "say ...images/" add a value for + multiple images named with an a,b,c,d, e etc. and the file extention (.jpg) and then be able to display that/those image(s) in the table.
Here is the code:
<!-- #include file="connectionstring.asp" -->
<%
'variables
dim Conn, Connstring, Sql_Get, TheArray, Recordset
'database connection
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Provider = provider
Conn.ConnectionString = dbasepath
Conn.Open
'Sql statement
Sql_Get="SELECT * FROM table ORDER BY id"
Set Recordset = Conn.Execute(Sql_Get)
' get the recordset data in memory using getrows()
TheArray = RecordSet.Getrows
' Cleanup objects
Conn.Close
Set Conn = Nothing
Set RecordSet = Nothing
%>
<%
' start an HTML table to contain the results.
Response.write "<table border=1 width=500 cellpadding=3>"
' start the loop
For x = 0 to UBound(TheArray,2)
'format & write out the results
Response.write "<TR><TD><font size='1'>"
Response.Write "<b>Property Type</b> " & TheArray(16,x) & "<br>"
Response.Write "<b>#:</b> " & TheArray(1,x) & "<br>"
Response.Write "<b>Location:</b> " & TheArray(2,x) & " " & TheArray(10,x) & ", " & TheArray(11,x) & ", " & TheArray(14,x) & " County" & ", " & TheArray(12,x) & "<br>"
Response.Write "<b>ZipCode:</b> 0" & TheArray(3,x) & "<br>"
if InStr(UCase(TheArray(4,x)), "HTTP://") = 1 then TheArray(4,x) = "<a href='" & TheArray(4,x) & "'>" & TheArray(4,x) & "</a>"
Response.Write "<b>Link:</b> " & TheArray(4,x) & "<br>"
Response.Write "<b>List Price $:</b> " & TheArray(13,x) & "<br>"
Response.Write "</font></TD></TR>"
' next position
Next
' close table
Response.write "</TABLE>"
%>
The OLD site actually used ASP.NET and I don't know how this worked, but this appears to..
<a href='<%# databinder.eval(container.dataitem, "ML Number", "relistings.aspx?mls={0}")%>' target="relisting">
<IMG border="0" src='<%# checkPix(databinder.eval(container.dataitem, "ML Number"))%>' width="151" height="121"></a>
any help is welcome.