Разберешься?
$bquery = array( 'SELECT' => 'MIN(bt.id), bt.subject', 'FROM' => 'topics AS bt', 'WHERE' => 'bt.id>'.$id, ); $bresult = $forum_db->query_build($bquery) or error(__FILE__, __LINE__); $back = $forum_db->fetch_assoc($bresult); if(isset($back['MIN(bt.id)'])) $tback = '<a href="'.forum_link($forum_url['topic'], array($back['MIN(bt.id)'], sef_friendly($back['subject']))).'">'.$back['subject'].'</a>'; $nquery = array( 'SELECT' => 'MAX(nt.id), nt.subject', 'FROM' => 'topics AS nt', 'WHERE' => 'nt.id<'.$id, ); $nresult = $forum_db->query_build($nquery) or error(__FILE__, __LINE__); $next = $forum_db->fetch_assoc($nresult); if(isset($next['MAX(nt.id)'])) $tnext = '<a href="'.forum_link($forum_url['topic'], array($next['MAX(nt.id)'], sef_friendly($next['subject']))).'">'.$next['subject'].'</a>'; echo $tback; echo $tnext;
will you understand?
Or second embodiment:
$query = array( 'SELECT' => 't.id, t.subject', 'FROM' => 'topics AS t', 'WHERE' => 't.forum_id='.$cur_topic['forum_id'] ); $result = $forum_db->query_build($query) or error(__FILE__, __LINE__); $back = array(); $next = array(); while($topics = $forum_db->fetch_assoc($result)) { if($topics['id'] < $id) $back[$topics['id']] = $topics['subject']; else if ($topics['id'] > $id) $next[$topics['id']] = $topics['subject']; } $back_id = max(array_keys($back)); $back_subject = $back[$back_id]; $next_id = min(array_keys($next)); $next_subject = $next[$next_id]; $tback = !empty($back_id) ? '<a href="'.forum_link($forum_url['topic'], array($back_id, sef_friendly($back_subject))).'" title="Old topic">'.$back_subject.' ◄◄ </a>' : ''; $tnext = !empty($next_id) ? '<a href="'.forum_link($forum_url['topic'], array($next_id, sef_friendly($next_subject))).'" title="Next topic"> ►► '.$next_subject.'</a>' : '';
I have tried it but i messed up at then end. Is there any alternate route to do so.....!
Infantigo