Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

csjr

Mostrar produtos aleatoriamente

Recommended Posts

opa!

to com um problema neste código....eu quero q sejam mostrados os produtos aleatoriamente, existem produtos marcados para serem mostrados na home page, mas smepre mostr ana mesma ordem, ja tentie de um jeito simples:

ORDER BY RND(idProduct), funciona, mas so funciona no servidor do websamba, rodando no proprio pc e em outros servidor (aspecto.net) tb naum funciona....ja tentie adaptar alguns codigo q vi aki mesmo no forum mas naum deu certo....

ai vai...(o prblema encontra-se a partir da linha

' get products marked as showInHome)

 

<!--#include file="../includes/settings.asp"-->

<!--#include file="../includes/getSettingKey.asp"-->

<!--#include file="../includes/sessionFunctions.asp"-->

<!--#include file="../includes/languages.asp"-->

<!--#include file="../includes/databaseFunctions.asp"-->

<!--#include file="../includes/currencyFormat.asp"-->

<!--#include file="../includes/switchLanguage.asp"-->

<!--#include file="../includes/specialPrice.asp"-->

<!--#include file="../includes/miscFunctions.asp"-->

 

<%

 

on error resume next

 

dim connTemp, rsTemp, rsTemp3, pRowsShown, pMaxPopularity

 

' get settings

pDefaultLanguage = getSettingKey("pDefaultLanguage")

pStoreFrontDemoMode = getSettingKey("pStoreFrontDemoMode")

pCurrencySign = getSettingKey("pCurrencySign")

pDecimalSign = getSettingKey("pDecimalSign")

pCompany = getSettingKey("pCompany")

pCompanyLogo = getSettingKey("pCompanyLogo")

 

pAuctions = getSettingKey("pAuctions")

pListBestSellers = getSettingKey("pListBestSellers")

pNewsLetter = getSettingKey("pNewsLetter")

pPriceList = getSettingKey("pPriceList")

pStoreNews = getSettingKey("pStoreNews")

pOneStepCheckout = getSettingKey("pOneStepCheckout")

pShowStockView = getSettingKey("pShowStockView")

pIdProductVip = getSettingKey("pIdProductVip")

 

' defines how many rows it will show in the home (consider that if there are no enough products you will get empty cells)

pRowsShown = getSettingKey("pRowsShown")

 

pMaxPopularity = 0

arrCounter = 0

pIdCustomer = getSessionVariable("idCustomer",0)

pIdCustomerType = getSessionVariable("idCustomerType",1)

 

' get how many products are marked as showInHome

 

mySQL="SELECT COUNT(idProduct) as howManyHome FROM products WHERE showInHome=-1 AND active=-1"

 

call getFromDatabase (mySql, rsTemp3, "dynamic_index")

 

if rsTemp3.eof then

howManyHome=0

else

howManyHome=rstemp3("howManyHome")

end if

 

if Cint(howManyHome)<Cint(pRowsShown*2) then

response.redirect "comersus_supportError.asp?error="&Server.Urlencode("Not enough ShowInHome products (" &howManyHome& ") to fill the Dynamic Index "&Cint(pRowsShown*2))

end if

 

' get VIP details

 

if pIdProductVip<>"" then

mySQL="SELECT details, smallImageUrl FROM products WHERE active=-1 AND idProduct="&pIdProductVip

 

call getFromDatabase (mySql, rsTemp3, "dynamic_index")

 

if rsTemp3.eof then

response.redirect "comersus_supportError.asp?error="&Server.Urlencode("VIP product is invalid")

end if

 

pDetailsVip =rstemp3("details")

psmallImageUrlVip =rstemp3("smallImageUrl")

 

' switch description and details depending on user selected language

switchProductsLanguage session("language"), pIdProductVip, pDetailsVip, "-"

 

end if

 

' get products marked as showInHome

 

mySQL="SELECT idProduct, description, details, price, smallImageUrl, stock, bToBPrice, visits FROM products WHERE showInHome=-1 AND active=-1 ORDER BY RND(idProduct)"

 

call getFromDatabase (mySql, rsTemp3, "dynamic_index")

 

if rsTemp3.eof then

response.redirect "comersus_message.asp?message="&Server.Urlencode(dictLanguage.Item(Session("language")&"_dynamicindex_1") )

end if

 

' define the array to store products (2 columns)

reDim arrProducts(pRowsShown*2,8)

 

' load the array only with spots available

 

do while (not rstemp3.eof) and arrCounter<(pRowsShown*2)

pIdProduct = rstemp3("idProduct")

pDescription = rstemp3("description")

pDetails = rstemp3("details")

 

' switch description and details depending on user selected language

switchProductsLanguage session("language"), pIdProduct, pDetails, pDescription

 

' load product array

arrProducts(arrCounter,0)= pIdProduct

arrProducts(arrCounter,1)= pDescription

' cut description only if it has no HTML tags insidem, check with BR tag only

if instr(arrProducts(arrCounter,2),"<BR>")=0 then arrProducts(arrCounter,2)= left(pDetails,180)&"..."

arrProducts(arrCounter,3)= rstemp3("price")

arrProducts(arrCounter,4)= rstemp3("smallImageUrl")

arrProducts(arrCounter,5)= rstemp3("stock")

arrProducts(arrCounter,6)= rstemp3("bToBprice")

arrProducts(arrCounter,7)= rstemp3("visits")

if instr(arrProducts(arrCounter,8),"<BR>")=0 then arrProducts(arrCounter,8)= left(pDetailsVip,250)&"..."

 

 

arrCounter = arrCounter+1

 

rstemp3.moveNext

loop

 

pMaxPopularity=getMax(arrProducts)

 

' get 1 to 100 main categories (root)

 

mySQL="SELECT idCategory, categoryDesc FROM categories WHERE idParentCategory=1 AND idCategory<>1 ORDER BY categoryDesc"

 

call getFromDatabase (mySql, rsTemp, "dynamic_index")

 

' define the array to store categories

reDim arrCategories(99999,1)

arrCounter=0

 

do while not rstemp.eof and arrCounter<99999

arrCategories(arrCounter,0)=rstemp("idCategory")

arrCategories(arrCounter,1)=rstemp("categoryDesc")

arrCounter=arrCounter+1

rstemp.movenext

loop

 

mySQL="SELECT idSupplier, supplierName FROM suppliers ORDER BY supplierName"

 

call getFromDatabase (mySql, rsTemp, "dynamic_index")

 

' define the array to store categories

reDim arrSuppliers(99999,1)

arrCounter=0

 

do while not rstemp.eof and arrCounter<99999

arrSuppliers(arrCounter,0)=rstemp("idSupplier")

arrSuppliers(arrCounter,1)=rstemp("supplierName")

arrCounter=arrCounter+1

rstemp.movenext

loop

 

 

 

%>

<!--#include file="header.asp"-->

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

<tr>

<td colspan=5>

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

<%if pIdProductVip<>"" then%>

<tr>

<td width="15%">

<%if psmallImageUrlVip<>"" then%>

<a href="comersus_viewItem.asp?idProduct=<%=pIdProductVip%>"><img align=left border=0 src="catalog/<%=psmallImageUrlVip%>" vspace=3></a>

<%else%>

<img src='catalog/imageNA.gif' alt="Image not available">

<%end if%>

</td>

<td width="80%"> <b>.:::<span style="height: 1; filter:glow(color=red)"> <font color="#FFFFFF">Promoção

do mês</font> </span>:::.</b><br>

<br>

<%=arrProducts(pItemCounter,8)%> <br>

<a href="comersus_viewItem.asp?idProduct=<%=pIdProductVip%>"><%=dictLanguage.Item(Session("language")&"_dynamicindex_2")%></a>

</td>

</tr>

<%end if%>

 

</table>

</td>

</tr>

<%

pItemCounter=0

for f=0 to pRowsShown-1

%>

<tr>

<td valign=top width="499"></td>

<!-- Column spacers begin -->

<td width=7> <img border=0 height=1 src="images/cleardot.gif" width=5></td>

<td width=1> <img border=0 height=1 src="images/cleardot.gif" width=1></td>

<td width=13><img border=0 height=1 src="images/cleardot.gif" width=9></td>

<!-- Column spacers end -->

<td width="467"></td>

</tr>

<tr>

<td colspan=5> <img border=0 height=5 src="images/cleardot.gif" width=1><br>

<img border=0 height=1 src="images/ruledot.gif" width="100%" vspace=5><br>

</td>

</tr>

<tr valign=top>

<td width="50%"> <img border=0 height=8 src="images/cleardot.gif" width=2><br>

 

<%if arrProducts(pItemCounter,4)<>"" then%>

<br><a href="comersus_viewItem.asp?idProduct=<%=arrProducts(pItemCounter,0)%>"><img align=left alt="<%=arrProducts(pItemCounter,1)%>" border=0 src="catalog/<%=arrProducts(pItemCounter,4)%>" vspace=3></a>

<%else%>

<img src='catalog/imageNA.gif' alt="Image not available">

<%end if%>

 

<b><%=arrProducts(pItemCounter,1)%></b>

<br><br>

<%=arrProducts(pItemCounter,2)%> <br>

<a href="comersus_viewItem.asp?idProduct=<%=arrProducts(pItemCounter,0)%>"><%=dictLanguage.Item(Session("language")&"_dynamicindex_2")%></a>

<br clear=left><img border=0 height=4 hspace=0 src="images/cleardot.gif" width=3>

<br>

<%if pIdCustomerType=1 or arrProducts(pItemCounter,6)=0 then%>

<%=dictLanguage.Item(Session("language")&"_dynamicindex_3") &pCurrencySign & money(arrProducts(pItemCounter,3))%>

<%else%>

<%=dictLanguage.Item(Session("language")&"_dynamicindex_3") &pCurrencySign & money(arrProducts(pItemCounter,6))%>

<%end if%>

<%if pShowStockView="-1" and arrProducts(pItemCounter,5)<>0 then%>

<font size="1"><i><%=dictLanguage.Item(Session("language")&"_dynamicindex_9")%></i></font>

<%else%>

<font size="1"><i><%=dictLanguage.Item(Session("language")&"_dynamicindex_12")%></i></font>

<%end if%>

 

<br><%=dictLanguage.Item(Session("language")&"_dynamicindex_11")%> <%=arrProducts(pItemCounter,7)%> <img border=0 src="images/<%=getPopularity(arrProducts(pItemCounter,7),pMaxPopularity)%>popular.gif">

<br><br><a href="comersus_addItem.asp?idProduct=<%=arrProducts(pItemCounter,0)%>"><img src="images/<%=pLanguage%>/small_addCart.gif" border="0"></a>

<%pItemCounter=pItemCounter+1%>

 

<!-- DO NOT REMOVE -- SPACER GIF FOR BOXES --><br>

<img border=0 height=1 src="images/cleardot.gif" width=250 hspace=0><br>

<img border=0 height=10 src="images/cleardot.gif" width=170> </td>

<%' column %>

<td width=7> <img border=0 height=1 src="images/cleardot.gif" width=5></td>

<td width=1 bgcolor=#000000><img border=0 height="100%" src="images/ruledot.gif" width=1></td>

<td width=13> <img border=0 height=1 src="images/cleardot.gif" width=9></td>

<%' Cell 2 %>

<td width="50%"> <img border=0 height=10 src="images/cleardot.gif" width=205><br>

 

<%if arrProducts(pItemCounter,4)<>"" then%>

<br><a href="comersus_viewItem.asp?idProduct=<%=arrProducts(pItemCounter,0)%>"><img align=left alt="<%=arrProducts(pItemCounter,1)%>" border=0 src="catalog/<%=arrProducts(pItemCounter,4)%>" vspace=3></a>

<%else%>

<img src='catalog/imageNA.gif' alt="Image not available">

<%end if%>

 

<b><%=arrProducts(pItemCounter,1)%></b>

<br><br><%=arrProducts(pItemCounter,2)%>

<br><a href="comersus_viewItem.asp?idProduct=<%=arrProducts(pItemCounter,0)%>"><%=dictLanguage.Item(Session("language")&"_dynamicindex_2")%></a>

<br clear=left><img border=0 height=4 hspace=0 src="images/cleardot.gif" width=3>

<br>

 

<%if pIdCustomerType=1 or arrProducts(pItemCounter,6)=0 then%>

<%=dictLanguage.Item(Session("language")&"_dynamicindex_3") &pCurrencySign & money(arrProducts(pItemCounter,3))%>

<%else%>

<%=dictLanguage.Item(Session("language")&"_dynamicindex_3") &pCurrencySign & money(arrProducts(pItemCounter,6))%>

<%end if%>

 

<%if pShowStockView="-1" and arrProducts(pItemCounter,5)<>0 then%>

<font size="1"><i><%=dictLanguage.Item(Session("language")&"_dynamicindex_9")%></i></font>

<%else%>

<font size="1"><i><%=dictLanguage.Item(Session("language")&"_dynamicindex_12")%></i></font>

<%end if%>

 

<br><%=dictLanguage.Item(Session("language")&"_dynamicindex_11")%> <%=arrProducts(pItemCounter,7)%> <img border=0 src="images/<%=getPopularity(arrProducts(pItemCounter,7),pMaxPopularity)%>popular.gif">

<br>

<br>

<a href="comersus_addItem.asp?idProduct=<%=arrProducts(pItemCounter,0)%>"><img src="images/<%=pLanguage%>/small_addCart.gif" border="0"></a>

<%pItemCounter=pItemCounter+1%>

 

<!-- DO NOT REMOVE -- SPACER GIF FOR BOXES --><br>

<img border=0 height=1 src="images/cleardot.gif" width=250 hspace=0 ><br>

<img border=0 height=10 src="images/cleardot.gif" width=170> </td>

</tr>

<%next%>

 

<tr>

<td colspan=5>

<img border=0 height=5 src="images/cleardot.gif" width=1><br>

<img border=0 height=1 src="images/ruledot.gif" vspace=5 width="100%"><br>

<%' featured categories%>

<br><b><%=dictLanguage.Item(Session("language")&"_dynamicindex_10")%></b>:

<%

' only shows 99999 categories

if arrCounter>99999 then arrCounter=99999

for h=0 to arrCounter-1%>

<%=h+1%>. <a href="comersus_listCategoriesAndProducts.asp?idCategory=<%=arrCategories(h,0)%>"><%=arrCategories(h,1)%></a>

<%if h<99999 then%>

|

<%end if%>

<%next%>

<br>

<%' Fabricantes%>

<br><b>Fabricantes</b>:

<%

' only shows 99999 fabricantes

if arrCounter>99999 then arrCounter=99999

for h=0 to arrCounter-1%>

<%=h+1%>. <a href="comersus_listProductsBySupplier.asp?idSupplier=<%=arrSuppliers(h,0)%>"><%=arrSuppliers(h,1)%></a>

<%if h<99999 then%>

|

<%end if%>

<%next%>

 

<!--#include file="comersus_optBringRandomProduct.asp"-->

 

<br>

 

<%if pStoreFrontDemoMode="-1" and pAuctions="0" then%>

<a href="comersus_message.asp?message=<%=Server.UrlEncode("This feature is not installed. Purchase Power Packs at http://www.comersus.com/store")%>&...%></a> (new!) |

<%elseIf pAuctions="-1" then%>

<a href="comersus_optAuctionListAll.asp?redirectUrl=comersus_optauctionlistall.asp"><%=dictLanguage.Item(Session("language")&"_dynamicindex_4")%></a> (new!) |

<%end if%>

 

<%if pStoreFrontDemoMode="-1" and pListBestSellers="0" then%>

| <a href="comersus_message.asp?message=<%=Server.UrlEncode("This feature is not installed. Purchase Power Packs at http://www.comersus.com/store")%>&...;">Best Sellers </a>

<%elseIf pListBestSellers="-1" then%>

| <a href="comersus_optListBestSellers.asp"><%=dictLanguage.Item(Session("language")&"_dynamicindex_7")%></a>

<%end if%>

 

 

 

</td>

</tr>

</table>

 

<%call closeDb()%>

<!--#include file="footer.asp"-->

Compartilhar este post


Link para o post
Compartilhar em outros sites

www.clubemasters.com.br/forumcara, nesse forum tem uns codigos sobre Aleatórios!!! dá uma olhada!! falows

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.