следующее ( значение id > $artc_id )работает прекрасно.
id < $artc_id выводит всё время одно и то же значение, самое первое id в категории статей.
Подскажите пожалуйста.
/**********Number of Article and Number of its category*************/ $artc_id = $inDB->get_field('cms_content',"seolink = '$seolink'",'id'); $cat_id = $inDB->get_field('cms_content',"seolink = '$seolink'",'category_id'); /***********************/ if ($do != 'read' || !$seolink) {return false;} $prev = $inDB->get_fields('cms_content',"category_id = '$cat_id' AND id < $artc_id AND published = 1 ",'id,title,seolink,rating,hits'); if($prev){ $prev['image'] = (file_exists(PATH.'/images/photos/small/article'.$prev['id'].'.jpg') ? '/images/photos/small/article'.$prev['id'].'.jpg' : '/images/photos/no_image.png'); $prevcontent[] = $prev; } $next = $inDB->get_fields('cms_content',"category_id = '$cat_id' AND id > $artc_id AND published = 1 ",'id,title,seolink,rating,hits'); if($next){ $next['image'] = (file_exists(PATH.'/images/photos/small/article'.$next['id'].'.jpg') ? '/images/photos/small/article'.$next['id'].'.jpg' : '/images/photos/no_image.png'); $nextcontent[] = $next; }
ORDER BY id DESC LIMIT 1
$prev = $inDB->orderBy('id', 'DESC','LIMIT 1');
/**********Number of Article and Number of its category*************/ $artc_id = $inDB->get_field('cms_content',"seolink = '$seolink'",'id'); $cat_id = $inDB->get_field('cms_content',"seolink = '$seolink'",'category_id'); /***********************/ if ($do != 'read' || !$seolink) {return false;} $prev_id =$inDB->get_field('cms_content',"category_id = '$cat_id' AND id < $artc_id ",'id'); $next_id =$inDB->get_field('cms_content',"category_id = '$cat_id' AND id > $artc_id",'id'); $prev = $inDB->get_fields('cms_content',"id = $prev_id AND published = 1 ",'id,title,seolink,rating,hits'); if($prev){ $prev['image'] = (file_exists(PATH.'/images/photos/small/article'.$prev['id'].'.jpg') ? '/images/photos/small/article'.$prev['id'].'.jpg' : '/images/photos/no_image.png'); $prevcontent[] = $prev; } $next = $inDB->get_fields('cms_content',"id = $next_id AND published = 1 ",'id,title,seolink,rating,hits'); if($next){ $next['image'] = (file_exists(PATH.'/images/photos/small/article'.$next['id'].'.jpg') ? '/images/photos/small/article'.$next['id'].'.jpg' : '/images/photos/no_image.png'); $nextcontent[] = $next; }