Forums

ASP

This topic is locked

Help! Please

Posted 28 Sep 2006 22:11:24
1
has voted
28 Sep 2006 22:11:24 bry keen posted:
I am trying to display images from 1 recordset while displaying data from another and looping them combined in a table. Everything works fine except it is looping 1 image over and over, and the image relating to the data is not being displayed.
Here is the code. Thanks in advance.
------------------------------------------------
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="../Connections/premier.asp" -->
<%
Dim New_Listing__MMColParam
New_Listing__MMColParam = "1"
If (Request("MM_EmptyValue" <> "" Then
New_Listing__MMColParam = Request("MM_EmptyValue"
End If
%>
<%
Dim New_Listing
Dim New_Listing_cmd
Dim New_Listing_numRows

Set New_Listing_cmd = Server.CreateObject ("ADODB.Command"
New_Listing_cmd.ActiveConnection = MM_premier_STRING
New_Listing_cmd.CommandText = "SELECT * FROM dbo.CURRENT_LISTINGS WHERE Date_Entered BETWEEN '9/15/2006' and '9/22/2006'"
New_Listing_cmd.Prepared = true
New_Listing_cmd.Parameters.Append New_Listing_cmd.CreateParameter("param1", 200, 1, 50, New_Listing__MMColParam) ' adVarChar

Set New_Listing = New_Listing_cmd.Execute
New_Listing_numRows = 0
%>
<%
Dim Recordset1__MMColParam
Recordset1__MMColParam = "1"
If (New_Listing.Fields.Item("MLS#".Value <> "" Then
Recordset1__MMColParam = New_Listing.Fields.Item("MLS#".Value
End If
%>
<%
Dim Recordset1
Dim Recordset1_cmd
Dim Recordset1_numRows

Set Recordset1_cmd = Server.CreateObject ("ADODB.Command"
Recordset1_cmd.ActiveConnection = MM_premier_STRING
Recordset1_cmd.CommandText = "SELECT PhotoName FROM dbo.imgList WHERE MLS = 'MLS#' ORDER BY MLS ASC"
Recordset1_cmd.Prepared = true
Recordset1_cmd.Parameters.Append Recordset1_cmd.CreateParameter("param1", 200, 1, 50, Recordset1__MMColParam) ' adVarChar

Set Recordset1 = Recordset1_cmd.Execute
Recordset1_numRows = 0
%>
<%
Dim Recordset2__MMColParam
Recordset2__MMColParam = "0"
If (New_Listing.Fields.Item("MLS#".Value <> "" Then
Recordset2__MMColParam = New_Listing.Fields.Item("MLS#".Value
End If
%>
<%
Dim Recordset2
Dim Recordset2_cmd
Dim Recordset2_numRows

Set Recordset2_cmd = Server.CreateObject ("ADODB.Command"
Recordset2_cmd.ActiveConnection = MM_premier_STRING
Recordset2_cmd.CommandText = "SELECT * FROM dbo.imgList WHERE MLS = ?"
Recordset2_cmd.Prepared = true
Recordset2_cmd.Parameters.Append Recordset2_cmd.CreateParameter("param1", 200, 1, 50, Recordset2__MMColParam) ' adVarChar

Set Recordset2 = Recordset2_cmd.Execute
Recordset2_numRows = 0
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index

Repeat1__numRows = 10
Repeat1__index = 0
New_Listing_numRows = New_Listing_numRows + Repeat1__numRows
%>



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
<!-- -->
<%
While ((Repeat1__numRows <> 0) AND (NOT New_Listing.EOF))
%>
<table width="816" border="1">
<tr>
<td width="233"><%=(New_Listing.Fields.Item("Property_Address".Value)%></td>
<td width="181"><%=(New_Listing.Fields.Item("List_Date".Value)%></td>
<td width="220"><%=(New_Listing.Fields.Item("Date_Entered".Value)%></td>
<td width="154"> </td>
</tr>
<tr>
<td><img src="www.premier.com/listingsphotos-all/<%=(Recordset2.Fields.Item("PhotoName".Value)%>" width="165" border="0" /></a></td>
<td></td>
<td><%=(New_Listing.Fields.Item("LID".Value)%></td>
<td> </td>
</tr>
<tr>
<td><%=(New_Listing.Fields.Item("MLS#".Value)%></td>
<td></td>
<td><%=(Recordset2.Fields.Item("PhotoName".Value)%></td>
<td> </td>
</tr>
</table>
<%
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
New_Listing.MoveNext()
Wend
%>
<p><img src="www.premier.com/listingsphotos-all/<%=(Recordset2.Fields.Item("PhotoName".Value)%>" /></p>
</body>
</html>
<%
New_Listing.Close()
Set New_Listing = Nothing
%>
<%
Recordset1.Close()
Set Recordset1 = Nothing
%>
<%
Recordset2.Close()
Set Recordset2 = Nothing
%>

Replies

Replied 29 Sep 2006 12:29:34
29 Sep 2006 12:29:34 Vince Baker replied:
you need to move the recordset2 code under the start of the repeat region so each time the repeat region is run the id will increment and filter recordset2 correctly.

Regards

Vince Baker
<strong>DMX Zone Manager</strong>

[VBScript | ASP | HTML | CSS | SQL | Oracle | AS400 | ERP Logic | Hosting]

Reply to this topic