Hi, I wonder if anyone can help. I have this asp which selects randomly from my database. works fine but writes the results to a table. One of the returned results is an image so I need to wrap it in src. Problem is it wraps all the results in src. Anyone suggest a way to write the results so that one can custom each individually?
Any help would be great.
Thanks
Richard
Any help would be great.
Thanks
Richard
Code:
<% 'declare your variables dim connection, recordset, sConnString, sql dim intRandomNumber, intTotalRecords, i 'declare SQL statement that will query your database sql = "Select author, ThumbnailURL, downloadseven FROM tblgreetone where extrathree = 'yes' ORDER BY Authortwo asc" 'create ADO connection and recordset object Set connection = Server.CreateObject("ADODB.Connection") Set recordset = Server.CreateObject("ADODB.Recordset") 'define the connection string, specify database 'driver and the location of database sConnString="PROVIDER=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=" & Server.MapPath("/fpdb/greetingcardpro.mdb") 'Open the connection to the database connection.Open(sConnString) 'Open the recordset object executing the SQL recordset.Open sql, connection, 3, 1 'count the number of records and hold this is the variable intTotalRecords intTotalRecords = recordset.RecordCount Randomize() intRandomNumber = Int(intTotalRecords * Rnd) 'move to the random number returned recordset.Move intRandomNumber 'open the table Response.write("<table border='0'>") 'loop through the total number of fields For i = 0 to recordset.Fields.Count - 1 'write out the field value Response.write("<tr><td><img src=""" & recordset(i) & """></td></tr>") Next 'close the table response.write("</table>") 'close the recordset and connection objects and free up resources recordset.Close Set recordset=Nothing connection.close Set connection=Nothing %>
Comment