calculating pagination offset of specific row/offset
there is a function for showing posts (pleas ignore syntax errors )
function get_all_posts ($offset = 0 )
{
$q = $db->query("select * from tbl limit 10 offset $offset ");
$template->load_view('posts' , $q );
}
now lets say i have function called get_one_post with a single post offset
and total posts count as argument
function get_one_post($requested_post_offset = 0 , $totl_posts_count = 0 )
{
}
basically what i want to do in this get_one_post is to calculate page
offset of requested_post and call get_all_posts function , so it show the
page that contains that specific post
function get_one_post($requested_post_offset = 0 , $totl_posts_count = 0 )
{
$page_offset = // calculation( $requested_post_offset ,
$totl_posts_count );
get_all_posts ($page_offset);
}
i can say
get_all_posts ($requested_post_offset );
but it shows requested post as first post in the page ... but i wan to be
in it's natural place in the pagination not the first one
how should i do the calculation part ?
No comments:
Post a Comment