<%
'Load 5 last products and randomly pick 1
set rsProducts = server.createobject("ADODB.recordset")
rsProducts.cursortype = 3
strSQL = "SELECT TOP 5 products.product_ID, product_cat_ID, newPrice, product_name, product_image FROM products INNER JOIN product_description ON products.product_ID = product_description.product_ID WHERE product_lang_ID = " & session("language_ID") & " ORDER BY products.product_ID DESC;"
rsProducts.open strSQL, adoCon
if not rsProducts.eof then
newProducts = 1
strProducts = ""
do while not rsProducts.eof
if len(strProducts) = 0 then
strProducts = rsProducts("product_ID")
else
strProducts = strProducts & ";" & rsProducts("product_ID")
end if
rsProducts.movenext
loop
rsProducts.movefirst
arrProducts = split(strProducts, ";")
if ubound(arrProducts) > 0 then
'more then 1 product --> randomize
randomize()
intNumber = Int(ubound(arrProducts) * rnd())
if len(strImage) > 0 then
if instr(strImage, ";") > 0 then
strImage = left(strImage, instr(strImage, ";") - 1)
end if
strImage = "products/" & strImage
else
strImage = "no_picture.jpg"
end if
end if
rsProducts.close
set rsProducts = nothing
%>
<h2>
<a href="javascript:switchBox('lastProducts');">
</a>
</h2>
<div id="lastProducts_content" class="<%=getStatus("lastProducts")%>" align="center">
<%
if newProducts = 1 then
response.write "<a href=""?mod=product&product_ID=" & product_ID & "&cat_ID=" & getLink(product_cat_id) & """>" & chr(10) & _
" <img src=""images/" & strImage & """ width=""80"" alt=""" & product_name & """ title=""" & product_name & """ /><br />" & chr(10) & _
" " & product_name & "<br />" & chr(10) & _
"</a>" & chr(10) & _
roundNumber(product_price) & strCurrency
else
response.write "There are no new products"
end if
%>
</div>
</div>
<br />
<% end if %>