problem with repeat region

Ask a Question related to Dreamweaver AppDev, Design and Development.

  1. #1

    Default problem with repeat region

    i'm currently doing an ecommerce website for my project. using dreamweaver and
    access for the database btw. so here's a brief description of how the website
    works.

    i have a meatPoultry.asp page which consists of the links to all the recipes
    stored in the database. once clicked on a recipe link, it goes to the detail
    page recipe.asp. i have a recordset on this recipe.asp page, of which i (INNER)
    join 2 tables -Recipes and Ingredients. the relationship between these 2 tables
    is one-to-many. this recipe.asp page is to show the recipe title, ingredients
    and the method for the recipe selected.

    i added the repeat region behaviour onto the ingredients row. the problem here
    is that, when previewed in browser, all the records in the Ingredients table is
    shown. i only want the ingredients to the recipe selected to be shown.

    i don't think the problem lies with my database cos when i take away the
    repeat region, the first record (in Ingredients table) of the recipe selected,
    is shown, but i need all the ingredients to appear so the obvious thing to do
    is to use Repeat Region right? or something else?

    i've attached the code. someone help me pleassssseeeee......getting desperate
    here....:frown;

    <%
    Dim rsRecipe
    Dim rsRecipe_numRows

    Set rsRecipe = Server.CreateObject("ADODB.Recordset")
    rsRecipe.ActiveConnection = MM_conn_cyberKitchen_STRING
    rsRecipe.Source = "SELECT * FROM Recipes INNER JOIN Ingredients ON
    Recipes.RecipeID = Ingredients.RecipeID"
    rsRecipe.CursorType = 0
    rsRecipe.CursorLocation = 2
    rsRecipe.LockType = 1
    rsRecipe.Open()

    rsRecipe_numRows = 0
    %>
    <%
    Dim Repeat1__numRows
    Dim Repeat1__index

    Repeat1__numRows = -1
    Repeat1__index = 0
    rsRecipe_numRows = rsRecipe_numRows + Repeat1__numRows
    %>
    <%
    ' *** Recordset Stats, Move To Record, and Go To Record: declare stats
    variables

    Dim rsRecipe_total
    Dim rsRecipe_first
    Dim rsRecipe_last

    ' set the record count
    rsRecipe_total = rsRecipe.RecordCount

    ' set the number of rows displayed on this page
    If (rsRecipe_numRows < 0) Then
    rsRecipe_numRows = rsRecipe_total
    Elseif (rsRecipe_numRows = 0) Then
    rsRecipe_numRows = 1
    End If

    ' set the first and last displayed record
    rsRecipe_first = 1
    rsRecipe_last = rsRecipe_first + rsRecipe_numRows - 1

    ' if we have the correct record count, check the other stats
    If (rsRecipe_total <> -1) Then
    If (rsRecipe_first > rsRecipe_total) Then
    rsRecipe_first = rsRecipe_total
    End If
    If (rsRecipe_last > rsRecipe_total) Then
    rsRecipe_last = rsRecipe_total
    End If
    If (rsRecipe_numRows > rsRecipe_total) Then
    rsRecipe_numRows = rsRecipe_total
    End If
    End If
    %>

    <%
    Dim MM_paramName
    %>
    <%
    ' *** Move To Record and Go To Record: declare variables

    Dim MM_rs
    Dim MM_rsCount
    Dim MM_size
    Dim MM_uniqueCol
    Dim MM_offset
    Dim MM_atTotal
    Dim MM_paramIsDefined

    Dim MM_param
    Dim MM_index

    Set MM_rs = rsRecipe
    MM_rsCount = rsRecipe_total
    MM_size = rsRecipe_numRows
    MM_uniqueCol = "RecipeID"
    MM_paramName = "RecipeID"
    MM_offset = 0
    MM_atTotal = false
    MM_paramIsDefined = false
    If (MM_paramName <> "") Then
    MM_paramIsDefined = (Request.QueryString(MM_paramName) <> "")
    End If
    %>
    <%
    ' *** Move To Specific Record: handle detail parameter

    If (MM_paramIsDefined And MM_rsCount <> 0) Then

    ' get the value of the parameter
    MM_param = Request.QueryString(MM_paramName)

    ' find the record with the unique column value equal to the parameter value
    MM_offset = 0
    Do While (Not MM_rs.EOF)
    If (CStr(MM_rs.Fields.Item(MM_uniqueCol).Value) = MM_param) Then
    Exit Do
    End If
    MM_offset = MM_offset + 1
    MM_rs.MoveNext
    Loop

    ' if not found, set the number of records and reset the cursor
    If (MM_rs.EOF) Then
    If (MM_rsCount < 0) Then
    MM_rsCount = MM_offset
    End If
    If (MM_size < 0 Or MM_size > MM_offset) Then
    MM_size = MM_offset
    End If
    MM_offset = 0

    ' reset the cursor to the beginning
    If (MM_rs.CursorType > 0) Then
    MM_rs.MoveFirst
    Else
    MM_rs.Close
    MM_rs.Open
    End If
    End If

    End If
    %>
    <%
    ' *** Move To Record: if we dont know the record count, check the display range

    If (MM_rsCount = -1) Then

    ' walk to the end of the display range for this page
    MM_index = MM_offset
    While (Not MM_rs.EOF And (MM_size < 0 Or MM_index < MM_offset + MM_size))
    MM_rs.MoveNext
    MM_index = MM_index + 1
    Wend

    ' if we walked off the end of the recordset, set MM_rsCount and MM_size
    If (MM_rs.EOF) Then
    MM_rsCount = MM_index
    If (MM_size < 0 Or MM_size > MM_rsCount) Then
    MM_size = MM_rsCount
    End If
    End If

    ' if we walked off the end, set the offset based on page size
    If (MM_rs.EOF And Not MM_paramIsDefined) Then
    If (MM_offset > MM_rsCount - MM_size Or MM_offset = -1) Then
    If ((MM_rsCount Mod MM_size) > 0) Then
    MM_offset = MM_rsCount - (MM_rsCount Mod MM_size)
    Else
    MM_offset = MM_rsCount - MM_size
    End If
    End If
    End If

    ' reset the cursor to the beginning
    If (MM_rs.CursorType > 0) Then
    MM_rs.MoveFirst
    Else
    MM_rs.Requery
    End If

    ' move the cursor to the selected record
    MM_index = 0
    While (Not MM_rs.EOF And MM_index < MM_offset)
    MM_rs.MoveNext
    MM_index = MM_index + 1
    Wend
    End If
    %>
    <%
    ' *** Move To Record: update recordset stats

    ' set the first and last displayed record
    rsRecipe_first = MM_offset + 1
    rsRecipe_last = MM_offset + MM_size

    If (MM_rsCount <> -1) Then
    If (rsRecipe_first > MM_rsCount) Then
    rsRecipe_first = MM_rsCount
    End If
    If (rsRecipe_last > MM_rsCount) Then
    rsRecipe_last = MM_rsCount
    End If
    End If

    ' set the boolean used by hide region to check if we are on the last record
    MM_atTotal = (MM_rsCount <> -1 And MM_offset + MM_size >= MM_rsCount)
    %>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    </head>

    <body>

    <table width="100%" border="0" cellspacing="0" cellpadding="0">


    <tr>
    <td><font face="Geneva, Arial, Helvetica,
    sans-serif"><strong><%=(rsRecipe.Fields.Item("RecipeNam e").Value)%></strong></fo
    nt></td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    </tr>
    </table>


    <br />
    <%
    While ((Repeat1__numRows <> 0) AND (NOT rsRecipe.EOF))
    %>
    <table width="100%" border="0" cellpadding="0" cellspacing="0">
    <tr>
    <td><%=(rsRecipe.Fields.Item("IngredientQty").Valu e)%>
    <%=(rsRecipe.Fields.Item("IngredientName").Value)% ></td>
    </tr>
    <tr>
    <td>&nbsp; </td>
    </tr>
    </table>
    <%
    Repeat1__index=Repeat1__index+1
    Repeat1__numRows=Repeat1__numRows-1
    rsRecipe.MoveNext()
    Wend
    %>
    <br />
    <p>&nbsp;</p>
    </body>
    </html>
    <%
    rsRecipe.Close()
    Set rsRecipe = Nothing
    %>

    siti_nana Guest

  2. Similar Questions and Discussions

    1. Nested Repeat region
      Before Upgrading to CS I used to use the Extension from those clever peps at InterAkt to do this but now for some reason its incompatible!!! ...
    2. repeat region
      Hi.. I use repeat region to view only 10 records at a time, so how can I have another link that when user click on next it will go to another 10 of...
    3. Repeat Region Question
      I have a repeat region section that contains news blips. I would like a horizonal rule beween them, but NOT the very last one. Is there a way to...
    4. repeat region across the page?
      Maybe a really silly question but my little brain could not work this out. How do you repeat a region across and down the page at the same time?...
    5. php repeat region
      Hey guys, question about PHP, I'm trying to help out a friend but I don't really know anything about php. I'm also pretty amaturish at asp. I...
  3. #2

    Default Re: problem with repeat region

    There is no WHERE clause in your SQL - the WHERE clause acts as a filter to
    limit the recordset. You'll need to pick up a querystring variable passed
    from the master page to the detail page and use that in the WHERE clause.

    Best - Joe

    "siti_nana" <webforumsuser@macromedia.com> wrote in message
    news:cv9q31$mdt$1@forums.macromedia.com...
    > i'm currently doing an ecommerce website for my project. using dreamweaver
    and
    > access for the database btw. so here's a brief description of how the
    website
    > works.
    >
    > i have a meatPoultry.asp page which consists of the links to all the
    recipes
    > stored in the database. once clicked on a recipe link, it goes to the
    detail
    > page recipe.asp. i have a recordset on this recipe.asp page, of which i
    (INNER)
    > join 2 tables -Recipes and Ingredients. the relationship between these 2
    tables
    > is one-to-many. this recipe.asp page is to show the recipe title,
    ingredients
    > and the method for the recipe selected.
    >
    > i added the repeat region behaviour onto the ingredients row. the problem
    here
    > is that, when previewed in browser, all the records in the Ingredients
    table is
    > shown. i only want the ingredients to the recipe selected to be shown.
    >
    > i don't think the problem lies with my database cos when i take away the
    > repeat region, the first record (in Ingredients table) of the recipe
    selected,
    > is shown, but i need all the ingredients to appear so the obvious thing to
    do
    > is to use Repeat Region right? or something else?
    >
    > i've attached the code. someone help me pleassssseeeee......getting
    desperate
    > here....:frown;
    >
    > <%
    > Dim rsRecipe
    > Dim rsRecipe_numRows
    >
    > Set rsRecipe = Server.CreateObject("ADODB.Recordset")
    > rsRecipe.ActiveConnection = MM_conn_cyberKitchen_STRING
    > rsRecipe.Source = "SELECT * FROM Recipes INNER JOIN Ingredients ON
    > Recipes.RecipeID = Ingredients.RecipeID"
    > rsRecipe.CursorType = 0
    > rsRecipe.CursorLocation = 2
    > rsRecipe.LockType = 1
    > rsRecipe.Open()
    >
    > rsRecipe_numRows = 0
    > %>
    > <%
    > Dim Repeat1__numRows
    > Dim Repeat1__index
    >
    > Repeat1__numRows = -1
    > Repeat1__index = 0
    > rsRecipe_numRows = rsRecipe_numRows + Repeat1__numRows
    > %>
    > <%
    > ' *** Recordset Stats, Move To Record, and Go To Record: declare stats
    > variables
    >
    > Dim rsRecipe_total
    > Dim rsRecipe_first
    > Dim rsRecipe_last
    >
    > ' set the record count
    > rsRecipe_total = rsRecipe.RecordCount
    >
    > ' set the number of rows displayed on this page
    > If (rsRecipe_numRows < 0) Then
    > rsRecipe_numRows = rsRecipe_total
    > Elseif (rsRecipe_numRows = 0) Then
    > rsRecipe_numRows = 1
    > End If
    >
    > ' set the first and last displayed record
    > rsRecipe_first = 1
    > rsRecipe_last = rsRecipe_first + rsRecipe_numRows - 1
    >
    > ' if we have the correct record count, check the other stats
    > If (rsRecipe_total <> -1) Then
    > If (rsRecipe_first > rsRecipe_total) Then
    > rsRecipe_first = rsRecipe_total
    > End If
    > If (rsRecipe_last > rsRecipe_total) Then
    > rsRecipe_last = rsRecipe_total
    > End If
    > If (rsRecipe_numRows > rsRecipe_total) Then
    > rsRecipe_numRows = rsRecipe_total
    > End If
    > End If
    > %>
    >
    > <%
    > Dim MM_paramName
    > %>
    > <%
    > ' *** Move To Record and Go To Record: declare variables
    >
    > Dim MM_rs
    > Dim MM_rsCount
    > Dim MM_size
    > Dim MM_uniqueCol
    > Dim MM_offset
    > Dim MM_atTotal
    > Dim MM_paramIsDefined
    >
    > Dim MM_param
    > Dim MM_index
    >
    > Set MM_rs = rsRecipe
    > MM_rsCount = rsRecipe_total
    > MM_size = rsRecipe_numRows
    > MM_uniqueCol = "RecipeID"
    > MM_paramName = "RecipeID"
    > MM_offset = 0
    > MM_atTotal = false
    > MM_paramIsDefined = false
    > If (MM_paramName <> "") Then
    > MM_paramIsDefined = (Request.QueryString(MM_paramName) <> "")
    > End If
    > %>
    > <%
    > ' *** Move To Specific Record: handle detail parameter
    >
    > If (MM_paramIsDefined And MM_rsCount <> 0) Then
    >
    > ' get the value of the parameter
    > MM_param = Request.QueryString(MM_paramName)
    >
    > ' find the record with the unique column value equal to the parameter
    value
    > MM_offset = 0
    > Do While (Not MM_rs.EOF)
    > If (CStr(MM_rs.Fields.Item(MM_uniqueCol).Value) = MM_param) Then
    > Exit Do
    > End If
    > MM_offset = MM_offset + 1
    > MM_rs.MoveNext
    > Loop
    >
    > ' if not found, set the number of records and reset the cursor
    > If (MM_rs.EOF) Then
    > If (MM_rsCount < 0) Then
    > MM_rsCount = MM_offset
    > End If
    > If (MM_size < 0 Or MM_size > MM_offset) Then
    > MM_size = MM_offset
    > End If
    > MM_offset = 0
    >
    > ' reset the cursor to the beginning
    > If (MM_rs.CursorType > 0) Then
    > MM_rs.MoveFirst
    > Else
    > MM_rs.Close
    > MM_rs.Open
    > End If
    > End If
    >
    > End If
    > %>
    > <%
    > ' *** Move To Record: if we dont know the record count, check the display
    range
    >
    > If (MM_rsCount = -1) Then
    >
    > ' walk to the end of the display range for this page
    > MM_index = MM_offset
    > While (Not MM_rs.EOF And (MM_size < 0 Or MM_index < MM_offset +
    MM_size))
    > MM_rs.MoveNext
    > MM_index = MM_index + 1
    > Wend
    >
    > ' if we walked off the end of the recordset, set MM_rsCount and MM_size
    > If (MM_rs.EOF) Then
    > MM_rsCount = MM_index
    > If (MM_size < 0 Or MM_size > MM_rsCount) Then
    > MM_size = MM_rsCount
    > End If
    > End If
    >
    > ' if we walked off the end, set the offset based on page size
    > If (MM_rs.EOF And Not MM_paramIsDefined) Then
    > If (MM_offset > MM_rsCount - MM_size Or MM_offset = -1) Then
    > If ((MM_rsCount Mod MM_size) > 0) Then
    > MM_offset = MM_rsCount - (MM_rsCount Mod MM_size)
    > Else
    > MM_offset = MM_rsCount - MM_size
    > End If
    > End If
    > End If
    >
    > ' reset the cursor to the beginning
    > If (MM_rs.CursorType > 0) Then
    > MM_rs.MoveFirst
    > Else
    > MM_rs.Requery
    > End If
    >
    > ' move the cursor to the selected record
    > MM_index = 0
    > While (Not MM_rs.EOF And MM_index < MM_offset)
    > MM_rs.MoveNext
    > MM_index = MM_index + 1
    > Wend
    > End If
    > %>
    > <%
    > ' *** Move To Record: update recordset stats
    >
    > ' set the first and last displayed record
    > rsRecipe_first = MM_offset + 1
    > rsRecipe_last = MM_offset + MM_size
    >
    > If (MM_rsCount <> -1) Then
    > If (rsRecipe_first > MM_rsCount) Then
    > rsRecipe_first = MM_rsCount
    > End If
    > If (rsRecipe_last > MM_rsCount) Then
    > rsRecipe_last = MM_rsCount
    > End If
    > End If
    >
    > ' set the boolean used by hide region to check if we are on the last
    record
    > MM_atTotal = (MM_rsCount <> -1 And MM_offset + MM_size >= MM_rsCount)
    > %>
    > <html xmlns="http://www.w3.org/1999/xhtml">
    > <head>
    > <title>Untitled Document</title>
    > <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"
    />
    > </head>
    >
    > <body>
    >
    > <table width="100%" border="0" cellspacing="0" cellpadding="0">
    >
    >
    > <tr>
    > <td><font face="Geneva, Arial, Helvetica,
    >
    sans-serif"><strong><%=(rsRecipe.Fields.Item("RecipeNam e").Value)%></strong>
    </fo
    > nt></td>
    > </tr>
    > <tr>
    > <td>&nbsp;</td>
    > </tr>
    > </table>
    >
    >
    > <br />
    > <%
    > While ((Repeat1__numRows <> 0) AND (NOT rsRecipe.EOF))
    > %>
    > <table width="100%" border="0" cellpadding="0" cellspacing="0">
    > <tr>
    > <td><%=(rsRecipe.Fields.Item("IngredientQty").Valu e)%>
    > <%=(rsRecipe.Fields.Item("IngredientName").Value)% ></td>
    > </tr>
    > <tr>
    > <td>&nbsp; </td>
    > </tr>
    > </table>
    > <%
    > Repeat1__index=Repeat1__index+1
    > Repeat1__numRows=Repeat1__numRows-1
    > rsRecipe.MoveNext()
    > Wend
    > %>
    > <br />
    > <p>&nbsp;</p>
    > </body>
    > </html>
    > <%
    > rsRecipe.Close()
    > Set rsRecipe = Nothing
    > %>
    >

    Joseph Lowery Guest

  4. #3

    Default Re: problem with repeat region

    can you give an example of what you meant? maybe in the form of codes or something.....would really appreciate it.... i'm not very code savvvy
    siti_nana Guest

  5. #4

    Default Re: problem with repeat region

    Kak long..
    rsRecipe.Source = "SELECT * FROM Recipes INNER JOIN Ingredients ON
    Recipes.RecipeID = Ingredients.RecipeID"

    from ur sql script there is no where clause so, ur above statementt will grab
    whatever values stored in ur db, so u have to filter it

    try putting as this one

    rsRecipe.Source = "SELECT * FROM Recipes INNER JOIN Ingredients ON
    Recipes.RecipeID = Ingredients.RecipeID
    where columnname[defineurcolumnhere]='ur values here'


    samkry Guest

  6. #5

    Default Re: problem with repeat region

    thks Abg Long! ;)
    siti_nana Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139