Okay so here is the final code. I will make plugin with some additional options in few days and upload on github. However anyone want to use this direct code here it is.
// get previous question
function get_prev_q(){
$myurl=$this->request;
$myurlpieces = explode("/", $myurl);
$myurl=$myurlpieces[0];
$query_p = "SELECT *
FROM ^posts
WHERE postid < $myurl
AND type='Q'
ORDER BY postid DESC
LIMIT 1";
$prev_q = qa_db_query_sub($query_p);
while($prev_link = qa_db_read_one_assoc($prev_q, true)){
$title = $prev_link['title'];
$pid = $prev_link['postid'];
echo '
<A HREF="'. qa_q_path_html($pid, $title) .'" title="'. $title .'" >← Prev Question </A>';
}
}
// get next question
function get_next_q(){
$myurl=$this->request;
$myurlpieces = explode("/", $myurl);
$myurl=$myurlpieces[0];
$query_n = "SELECT *
FROM ^posts
WHERE postid > $myurl
AND type='Q'
ORDER BY postid ASC
LIMIT 1";
$next_q = qa_db_query_sub($query_n);
while($next_link = qa_db_read_one_assoc($next_q, true)){
$title = $next_link['title'];
$pid = $next_link['postid'];
echo '
<A HREF="'. qa_q_path_html($pid, $title) .'" title="'. $title .'" STYLE="float:right">Next Question →</A>';
}
}
// adding next and previouls question links after all answer. This can be place anywhere you want just call get_prev_q() and get_next_q() functions
function a_list($a_list){
qa_html_theme_base::a_list($a_list);
$this->get_prev_q();
$this->get_next_q();
}
I would like to know if this code can be better.