$sql = mysql_query("select IBLOCK_ELEMENT_ID from `b_iblock_section_element`
where IBLOCK_SECTION_ID = '".$arResult["IBLOCK_SECTION_ID"]."' and IBLOCK_ELEMENT_ID in
(select ID from `b_iblock_element` where ACTIVE = 'Y' and WF_PARENT_ELEMENT_ID is NULL)") or die(mysql_error());
if (mysql_num_rows($sql) > 1)
{
$mas = array();
while ($f = mysql_fetch_assoc($sql))
{
$mas[] += $f['IBLOCK_ELEMENT_ID'];
}
foreach ($mas as $key=>$val)
if ($val == $arResult['ID']) $bigkey = $key;
//prev
if (isset($mas[$bigkey-1]))
{
?>
<a href="<?=$arResult["SECTION"]["SECTION_PAGE_URL"]?>&ELEMENT_ID=<?=$mas[$bigkey-1]?>"><< предыдущий товар</a>
<?php
}
//next
if (isset($mas[$bigkey+1]))
{
?>
<a href="<?=$arResult["SECTION"]["SECTION_PAGE_URL"]?>&ELEMENT_ID=<?=$mas[$bigkey+1]?>">следующий товар >></a>
<?php
}
}
|