tags:

views:

54

answers:

3

Hello i need to gater the data from db(MSSQL) in following way:

<div id="slider">
            <div class="scroll">

                <div class="scrollContainer">
                    <div class="listings">
                        <ul class="clear" id="navigation-feature">
                            <li class="list1" id="feature-tab1">
                                <a href="#"><img src="img/thumbnails/featured-1.jpg" alt="" title="" /><label>Francesca B&B</label>From €80</a>
                            </li>
                            <li class="list2" id="feature-tab2">
                                <a href="#"><img src="img/thumbnails/featured-2.jpg" alt="" title="" /><label>Condo Real Estate</label>$600</a>

                            </li>
                            <li class="list1" id="feature-tab3">
                                <a href="#"><img src="img/thumbnails/featured-3.jpg" alt="" title="" /><label>Washington House</label>$400</a>
                            </li>
                            <li class="list2" id="feature-tab4">
                                <a href="#"><img src="img/thumbnails/featured-4.jpg" alt="" title="" /><label>Cambridge</label>$650</a>
                            </li>

                        </ul>
                    </div>
                    <div class="listings">
                        <ul class="clear" id="navigation-feature2">
                            <li class="list1" id="feature-tab5">
                                <a href="#"><img src="img/thumbnails/featured-1.jpg" alt="" title="" /><label>Beach House</label>$900</a>
                            </li>
                            <li class="list2" id="feature-tab6">

                                <a href="#"><img src="img/thumbnails/featured-2.jpg" alt="" title="" /><label>Condo Real Estate</label>$600</a>
                            </li>
                            <li class="list1" id="feature-tab7">
                                <a href="#"><img src="img/thumbnails/featured-3.jpg" alt="" title="" /><label>Washington House</label>$400</a>
                            </li>
                            <li class="list2" id="feature-tab8">
                                <a href="#"><img src="img/thumbnails/featured-4.jpg" alt="" title="" /><label>Cambridge</label>$650</a>

                            </li>
                        </ul>
                    </div>
                </div>
            </div>
        </div>
    </div>

I have no ideea how to implement the recordset to get from 4 to for records and then to solve the problem of the
<div class="listings"> <ul class="clear" id="navigation-feature2"> as you could see after 4 records should increase also the navigation-feature2 and then navigation-feature3 .

Thank you

Now i have this and don't do the trick:

 <div id="slider">
            <div class="scroll" >
                <div class="scrollContainer">

                         <%Set oRS2 = Server.CreateObject("ADODB.Recordset")

                        oRS2.Open "Select * FROM prop_home where packageid='2'",xDb_Conn_Str,3,3
                        Set picRS2 = Server.CreateObject("ADODB.Recordset")
                        if not ors2.eof then


                        %>
                <div class="listings">
                        <ul class="clear" id="navigation-feature">
                <%do while not ors2.eof
                counter=counter+1
     picRS2.Open "Select picture FROM pictures where propid='"&ors2("propid")&"'",xDb_Conn_Str

                %>
                            <li class="list1" id="feature-tab<%=counter%>">
                                <a href="#"><img src="admin/uploads/<%=picrs2("picture")%>" alt="" title="" style="height:auto !important;max-height:104px;max-width:170px;width:auto !important;"/><label><%=ors2("name")%>From €<%=ors2("pricemin")%></label></a>
                            </li>
                            <%
                            picrs2.close
                            ors2.movenext
                            loop

                            end if%>

                        </ul>
                    </div>

                </div>
            </div>
        </div>
    </div>
+1  A: 

It looks like you're closing your database query within the loop

I'd recommend to read your data into arrays and loop over those rather than mixing data access and rendering logic.

edit

How about

<div id="slider">
    <div class="scroll" >
        <div class="scrollContainer">
<%
    Set oRS = Server.CreateObject("ADODB.Recordset")

    oRS.Open "Select ph.*, pic.picture FROM prop_home ph INNER JOIN pictures pic ON ph.propid = pictures.propid where ph.packageid='2'", xDb_Conn_Str, 3, 3

    If Not oRS.eof Then
%>
        <div class="listings">
            <ul class="clear" id="navigation-feature">

<%
         Do While Not oRS.eof
             counter = counter + 1
%>
                <li class="list1" id="feature-tab<%=counter%>">
                    <a href="#">
                        <img src="admin/uploads/<%=oRS("picture")%>" style="height:auto !important;max-height:104px;max-width:170px;width:auto !important;"/>
                        <label>
                            <%=oRS("name")%>From €<%=oRS("pricemin")%>
                        </label>
                    </a>
                 </li>
<%
             oRS.MoveNext
         Loop

         oRS.Close
%>
             </ul>
         </div>

<%

     End If
%>
     </div>
  </div>

I may err here too but you're closing one more <div/> than you open and you should enclose the (and surrounding <div/>) inside theIf block.

Filburt
picrs2.close should be inside the loop or else you get the error that recordset is open (ADODB.Recordset error '800a0e79'Operation is not allowed when the object is open. )don't think so? and about the getrow() yes will use that in the final production server for the moment i play like this .. but you didn't answer to my question
Teodor
@Teodor: Right, I mixed up picrs2 and ors2 there. How about querying everything in one query?
Filburt
@Teodor: see my updated answer - the magic number 4 is still a little unclear.
Filburt
Filburt one properties had more than one pic so your inner join won't work
Teodor
forgot to tell you that prop_home is a view so i managed to fix the innerjoin problem using a subquery inside the inner join
Teodor
+2  A: 

You need to ask the counter if mod 4 is 0 and change the listing number. Or a simple way is to add a second counter, and reset it every 4 cycles

Like this (Simplified code):

<div id="slider">
  <div class="scroll" >
    <div class="scrollContainer">
      <%Set oRS2 = Server.CreateObject("ADODB.Recordset")
      oRS2.Open "..."
      Set picRS2 = Server.CreateObject("ADODB.Recordset")
      dim FeatureCounter 
      FeatureCounter = 1
      if not ors2.eof then
         do while not ors2.eof
         counter=counter+1

         If featureCounter = 1 then
            %>
            <div class="listings">
               <ul class="clear" id="navigation-feature<%= trim(featureCounter)%>">
            <%
          end if
          ''// not good to open a new recordset for every record, 
          ''// but leave it here because is not the scope of the answer
          picRS2.Open "..."
          ''// you should also check if picRS2 not EOF
           %>
             <li class="list1" id="feature-tab<%=counter%>">
                <a href="#"><img src="..."></a>
             </li>
           <%
           picrs2.close


           If FeatureCounter = 4 then
              FeatureCounter = 1 ''//reset the counter
              %>
                </ul>
                </div>
              <%
           else
              FeatureCounter = FeatureCounter + 1
           end if


           ors2.movenext
           loop

           end if%>

        </div>
    </div>
</div>
Eduardo Molteni
very close thank you but unfortunatelly won't work , look at : http://tourscript.com/gabriele2/default3.asp is your example it generate all the time <div class="listings"> <ul class="clear" id="navigation-feature1">and it should be just one time then 4 of li and then <div class="listings"> <ul class="clear" id="navigation-feature2">
Teodor
Are you sure you added `FeatureCounter = FeatureCounter + 1` line at bottom?
Eduardo Molteni
yes exactly as in your example
Teodor
feature counter is always 1 it should become 2 after 4 records never get to 4
Teodor
however the problem are: id="navigation-feature" first is not 1 and second is id="navigation-feature2" if you look in my initial HTML and second every li should have an alternating class list1 and list2
Teodor
Teodor: Yes, I guess I missed a few details, but surely you got them right.
Eduardo Molteni
thank you Eduardo
Teodor
A: 

Made it ...

  <div id="slider">
            <div class="scroll">
                <div class="scrollContainer">
                     <%Set oRS2 = Server.CreateObject("ADODB.Recordset")

                        oRS2.Open "Select * FROM prop_home where packageid='2'",xDb_Conn_Str,3,3
                        Set picRS2 = Server.CreateObject("ADODB.Recordset")
                        if not ors2.eof then
                        dim FeatureCounter 
                          FeatureCounter = 1
                        othercounter=1 
                         do while not ors2.eof

                          counter=counter+1
                        if   featureCounter =1 then

        %>
                <div class="listings">
                         <ul class="clear" id="navigation-feature<%if othercounter <> 1 then  response.Write(othercounter) end if%>">
                   <%end if%>



                <%
     picRS2.Open "Select picture FROM pictures where propid='"&ors2("propid")&"'",xDb_Conn_Str

                If counter MOD 2 = 0 Then
                cl=2
                else 
                cl=1
                end if

                %>
                            <li class="list<%=cl%>" id="feature-tab<%=counter%>">
                                <a href="#"><img src="admin/uploads/<%=picrs2("picture")%>" alt="" title="" style="height:auto !important;max-height:104px;max-width:170px;width:auto !important;"/><label><%=ors2("name")%>From €<%=ors2("pricemin")%></label></a>
                            </li>
                           <% picrs2.close


       If FeatureCounter mod 4 = 0 then
         FeatureCounter = 1 ''//reset the counter

         othercounter = othercounter+1

 %>
                        </ul>
                    </div>
                    <%
        else
          FeatureCounter = FeatureCounter + 1
       end if


       ors2.movenext
       loop

       end if%>   </ul>
       </div>
                </div>
            </div>
        </div>
    </div>
Teodor