Im using the scrollExtend plugin to call a Json script which will spit out my content. This works fine on desktops and works well however my site is responsive and I will need this functionality to work on tablets and mobile devices aswell.
I have conducted a lot of test and I have narrowed it down to my Json script:
<?php
$parent_query = bb_query("SELECT f_children
FROM t_articles
WHERE f_id= '85' and (f_removed IS NULL or f_removed ='0')
");
$parent_row = bb_fetch_assoc($parent_query);
$children = explode(':',$parent_row['f_children']);
$i= 1;
$rowsperpage = 6;
$totalpages = count($children);
$_SESSION['highlights_current_page']++;
if (isset($_SESSION['highlights_current_page']) && is_numeric($_SESSION['highlights_current_page'])) {
$currentpage = (int) $_SESSION['highlights_current_page'];
}
if ($currentpage > $totalpages) {$currentpage = $totalpages;}
if ($currentpage < 1) {$currentpage = 1;}
$offset = ($currentpage-1) * $rowsperpage;
$x=0;
##take off earlier articles
while($x < $offset){
array_shift($children);
$x++;
}
##take off later articles
$children = array_slice($children, 0, $rowsperpage);
echo $_SESSION['highlights_current_page'];
echo "current:".$currentpage;
echo "total:".$totalpages;
echo "offset:".$offset;
foreach($children as $child)
{
$child_query = bb_query("
SELECT *
FROM t_articles
WHERE f_id = {$child}
and (f_removed IS NULL or f_removed ='0')
AND f_live ='1'
");
while ($row = bb_fetch_assoc($child_query)){
//data for echoing the articles
}
}
?>
When it is displayed on desktops and you scroll down it will then echo the next 6 articles and then if you continue the next 6 and so on. but for tablets it will echo the next 6 articles out and then it when you scroll down it will echo the same 6 articles over and over.
Here is my math for the blocks on desktops:
First echoed block of articles: $_SESSION['highlights_current_page']:2 current:2 total:20 offset:6
second echoed block of articles: $_SESSION['highlights_current_page']:3 current:3 total:20 offset:12
third echoed block of articles: $_SESSION['highlights_current_page']:4 current:4 total:20 offset:18
$_SESSION['highlights_current_page'] is the number of how many blocks it has echoed. e.g: the first six echoed would be 2 because six articles start off as displayed are classed as 1.
On tablets it will repeat:
First: $_SESSION['highlights_current_page']:2 current:2 total:20 offset:6
Second: $_SESSION['highlights_current_page']:2 current:2 total:20 offset:6
Third: $_SESSION['highlights_current_page']:2 current:2 total:20 offset:6
I'm rather new to programming for tablets is there something that I've added that wont work, or can anyone see the issue with my maths?
Thank you in advance