SQL statement invocation problem in ASP-home page How to call the recommended product

Source: Internet
Author: User

     title! Want to call the recommended product feature on the home page instead of ordering the call by Product ID, currently called from low to high, want to change to call the recommended product, code as follows

      <tr>       <TD height= "background=" images/l2.gif "><div class=" dd1 "> Products Center <span class=" YF ">product center</span><span class=" More ">  &nbsp     <img src= "Images/mor.gif" width= "7" height= "7"/> <a href= "products.asp" class= "Ma" > more ...</a></span></div></td>       </TR >       <tr>       <TD height= "235" valign= "Top" background= "Images/l2.gif" >       <%       set Rp=server. CreateObject ("Adodb.recordset")       sql= "select top 4 title,id,img  from products ORDER BY id DESC"       Rp.open sql,conn,1,1       If rp.eof and Rp.bof then       response. Write ("")       Else       Do While not rp.eof      %>       <div class= "Pro" > <a href= "SHOW.ASP?ID=<%=RP (" id ")%>" ><img src= "<%=RP (" img ")%>" alt= "<%=RP (" title ")%>" width= "108" height= "" border= "0"/></a>       <a href= " SHOW.ASP?ID=<%=RP ("id")%> "><%=rp (" title ")%></a></div>       <%       Rp.movenext       loop       End If       rp.close   &NBSP ;   Set rp=nothing      %>       </td>       </tr>     Solution:       First, see if you have a "recommended" setting in your background publishing product.       If not, you will need to modify the database to add a "recommended" field, such as istop (for example, data type, default value 0)       Product Management Department set recommendation, just modify the Istop value, such as RS ( "Istop") =1 (not 0 as a recommended product)       Then at the front desk so modified       sql= "select top 4 title,id,istop,img  from Product ORDER by Istop Desc,id desc "      The reason for the use of a by instead of a WHERE clause is to display when the recommendation is less than 4 items
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.