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 ?
---------------------------------EDIT----------------------------
please note that i know how to create and implement pagination ... that's not the issue here my framework pagination system works with offsets instead of page numbers .. like if per_page is 10 , pagination links would be like
page 1 => page.php?offset=0
page 2 => page.php?offset=10
page 3 => page.php?offset=20
in this example if the $requested_post_offset
is 15 then
THE PAGE OFFSET IS 10
and i should get the result of
page 2 => page.php?offset=10
get_one_post
function – max