Automatic page adding more items, ajax pagination?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: Automatic page adding more items, ajax pagination?

Post by simonmlewis »

I'm using this in all places:

Code: Select all

$sql->execute(array(':c' => $_GET['c']));
Is that wrong? Maybe I should be just using $c instead, but it's there.... where am I missing it?
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Automatic page adding more items, ajax pagination?

Post by Celauran »

simonmlewis wrote:but it's there.... where am I missing it?

Code: Select all

<a href='/infinite-scroll?p=<?php echo $next?>'>Next</a>
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: Automatic page adding more items, ajax pagination?

Post by simonmlewis »

Code: Select all

<a href='/infinite-scroll?p=<?php echo $next?>'>Next</a>
Do you mean this?

In theory it should therefore be:
<a href='/categ/$c/$category?p=<?php echo $next?>'>Next</a>

This is just making the animation scroll at the bottom. It's not reloading it.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Automatic page adding more items, ajax pagination?

Post by Celauran »

I haven't a clue if that's right; I'm not familiar with your URL structure. Given that it's currently pointing to /infinite-scroll and is currently working, I'm going to go with no.

Code: Select all

<a href='/infinite-scroll?c=<?= $c; ?>&p=<?php echo $next?>'>Next</a>
would be my guess.
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: Automatic page adding more items, ajax pagination?

Post by simonmlewis »

www.site.co.uk/categ/532/BRIGHT-SHIRT

Here is an example of the category page URL.
$c is the catid (or $row->catid).
$cname is the catname (or $row->catname).

Code: Select all

  <?php
  echo "<div class='nav'>
    <a href='/infinite-scroll?c=$c?p=";?><?php echo $next?>'>Next</a>
  </div>
  <?php endif?>
This still draws in the next lot, but it still isn't producing those further DIVs, and worse still, when I echo "$c" by the title, it shows for the first 44, but then stops thereafter.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Automatic page adding more items, ajax pagination?

Post by Celauran »

So what is /infinite-scroll?

Code: Select all

<?php
  echo "<div class='nav'>
    <a href='/infinite-scroll?c=$c?p=";?><?php echo $next?>'>Next</a>
  </div>
  <?php endif?>
This is completely broken.
You can't have two ? in your URL; you append a query string with ? and separate key/value pairs with &
Mismatched quotes
Bare words
endif with no opening if
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: Automatic page adding more items, ajax pagination?

Post by simonmlewis »

Sure, so I have changed it to:

Code: Select all

 <a href='/infinite-scroll?c=$c&p=";?><?php echo $next?>'>Next</a>
I've no idea what "infinite-scroll" is. It's not in the query file, nor anywhere else on here.

That bit has stumped me so much. If I change it to another word, it doesn't work. So goodness knows!
The endif is there from their code.
I have my own IFs in there, but they all have {} opening and close braces.

Code: Select all

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript" src="/js/infinite-scroll/jquery-ias.min.js"></script>
<script type="text/javascript">
  $(document).ready(function() {
    // Infinite Ajax Scroll configuration
    jQuery.ias({
      container : '.wrap', // main container where data goes to append
      item: '.home_popular', // single items
      pagination: '.nav', // page navigation
      next: '.nav a', // next page selector
      loader: '<img src="/js/infinite-scroll/ajax-loader.gif"/>', // loading gif
      triggerPageThreshold: 3 // show load more if scroll more than this
    });
  });
</script>
<link rel="stylesheet" media="all" href="/js/infinite-scroll/style.css">
<?php
require_once 'Mobile_Detect.php';
$detect = new Mobile_Detect;
include('dbconn.php');

$c = isset($_GET['c']) ? $_GET['c'] : null;
$cname = isset($_GET['cname']) ? $_GET['cname'] : null;
$query = ("SELECT * FROM categorybanners WHERE catid =:c");
$result = $pdo->prepare($query);
$result->execute(array(':c' => $_GET['c']));
$num_rows = $result->rowCount();

$query = ("SELECT categories FROM categories WHERE id =:c");
$result = $pdo->prepare($query);
$result->execute(array(':c' => $_GET['c']));
while ($row = $result->fetch(PDO::FETCH_OBJ)) 
      {
			echo "</div><div class='cat_head'><h1>$row->categories</h1></div>";
}


$query = ("SELECT * FROM categories WHERE id = :c AND introtext <> ''");
$result = $pdo->prepare($query);
$result->execute(array(':c' => $_GET['c']));

if (isset($_SESSION["loggedin"])) 
            {
            $usertype = $_SESSION["usertype"];
            if ($usertype == "admin")
              {
$num_rows = $result->rowCount();	
if ($num_rows == 0)
{
echo "<div class='cat_adminlink' style='float: left'><a href='/index.php?page=a_catbanners&ctype=cat&id=$c&p=y'><i class='fa fa-pencil-square-o'></i> Edit/Add Text</a></div>";
}
}
}
while ($row = $result->fetch(PDO::FETCH_OBJ)) 
      {
      echo "<div class='category_intro'>";

if (isset($_SESSION["loggedin"])) 
            {
            $usertype = $_SESSION["usertype"];
            if ($usertype == "admin")
              {
             echo "<div class='cat_adminlink'><a href='/index.php?page=a_catbanners&ctype=cat&id=$c&p=y'><i class='fa fa-pencil-square-o'></i> Edit/Add Text</a></div>";
             }
             }      
      
      echo "$row->introtext</div>";
      }
      
      
      echo "<div style='clear: both' /></div><div class='mainbodybox'>";



echo "<div class='categ_topbox'><div class='categ_subbox'>";
$query = "SELECT subname, subid, catname FROM products WHERE catid = :c AND pause = 'off' GROUP BY subname";
$result = $pdo->prepare($query);
$result->execute(array(':c' => $_GET['c']));
while ($row = $result->fetch(PDO::FETCH_OBJ)) 
{ 
 $subcateg = "$row->subname"; 
 $findsubcateg ="/ /"; 
 $replacesubcateg ="-"; 
 $subcategreplace = preg_replace ($findsubcateg, $replacesubcateg, $subcateg); 

 $categ = "$row->catname"; 
 $findcateg ="/ /"; 
 $replacecateg ="-"; 
 $categreplace = preg_replace ($findcateg, $replacecateg, $categ);  
 
echo "<div class='categ_subcateg'><a href='/subcateg/$c/$categreplace/$row->subid/$subcategreplace/'>$row->subname</a></div>";
}

echo "</div>";	



if (isset($_REQUEST['order'])) {
    $order = $_REQUEST['order'];
    $_SESSION['order'] = $_REQUEST['order'];
} else if (isset($_SESSION['order'])) {
    $order = $_SESSION['order'];
}

if(empty($_REQUEST['order']))
{ $order = "subname ASC";}

echo "<div class='categ_sortbox'><div class='";
if(isset($order))
{
if ($order == "title ASC") { echo "categ_orderon";}
else
{
echo "categ_order";
}
}
echo "'><a href='/categ/$c/$categreplace&order=title ASC' style='text-decoration: none'>A-Z</a></div>";

echo "<div class='";
if(isset($order))
{
if ($order == "title DESC") { echo "categ_orderon";}
else
{
echo "categ_order";
}
}
echo "'><a href='/categ/$c/$categreplace&order=title DESC' style='text-decoration: none'>Z-A</a></div>
<div class='";
if(isset($order))
{
if ($order == "price ASC") { echo "categ_orderon";}
else
{
echo "categ_order";
}
}

echo "'><a href='/categ/$c/$categreplace&order=price ASC' style='text-decoration: none'>Price (Low-High)</a></div>

<div class='";
if(isset($order))
{
if ($order == "price DESC") { echo "categ_orderon";}
else
{
echo "categ_order";
}
}
echo "'><a href='/categ/$c/$categreplace&order=price DESC' style='text-decoration: none'> (High-Low)</a></div>
</div><div style='clear: both; width: 500px'/></div></div><br/>";
  
if ( $detect->isMobile() && !$detect->isTablet() ) {
$limit = 30; #item per page
}
else
{
$limit = 44; #item per page
}

$page = (int) (!isset($_GET['p'])) ? 1 : $_GET['p'];
# sql query
$result = "SELECT * FROM products WHERE catid = :c AND pause = 'off' ORDER BY rcstock ASC, $order";
$sql = $pdo->prepare($result);
$sql->execute(array(':c' => $_GET['c']));
$num_rows = $sql->rowCount();
# find out query stat point
$start = ($page * $limit) - $limit;
# query for page navigation
if(($num_rows) > ($page * $limit) ){
  $next = ++$page;

}
$num_rows = 0;
  $count = 0;
$query = $result . " LIMIT $start, $limit";
$sql = $pdo->prepare($query);
$sql->execute(array(':c' => $_GET['c']));
$num_rows = $sql->rowCount();
if ($num_rows < 1) {
    header("HTTP/1.1 404 Not Found", true, 404);
    include ("custom_404.php");
    exit();
}
?>
<div class="wrap">

  <!-- loop row data -->
  <?php while ($row = $sql->fetch(PDO::FETCH_OBJ)):
  $count ++;
  $todaydate = date('Y-m-d');
  $backinstock = NULL;
  $newdate = strtotime("$todaydate");
  $datebackinstock = strtotime($row->datebackinstock);
  $i=30;
  $checkBackinstock = strtotime(date("Y-m-d", strtotime($row->datebackinstock)) . " +".$i."days");
  if ($checkBackinstock >= $newdate) { $backinstock = "enable"; }
      
  $title = $row->title; 
  $findtitle ="/ /"; 
  $replacetitle ="-"; 
  $titlereplace = preg_replace ($findtitle, $replacetitle, $title); 
  
  $categ = $row->catname; 
  $findcateg ="/ /"; 
  $replacecateg ="-"; 
  $categreplace = preg_replace ($findcateg, $replacecateg, $categ); 
  
  $subcateg = $row->subname; 
  $findsubcateg ="/ /"; 
  $replacesubcateg ="-"; 
  $subcategreplace = preg_replace ($findsubcateg, $replacesubcateg, $subcateg); 
 
  echo "<div class='home_popular'";
   if (($count % 4) == 0)
      {
      echo " style=' margin-right: 0px' ";
      }
      echo "><b>here</b>";
      
   if(isset($backinstock) && $row->pricedropenable != "yes" && $row->rcstock == "in stock")
    {
    if ($backinstock == "enable") 
      { 
      echo "<div id='home_popular_backinstock'><a href='/product/$row->catid/$categreplace/$row->subid/$subcategreplace/$row->id/$titlereplace'>&#10004; BACK IN STOCK</a></div>";
      }
    }
  if(isset($row->pricedropenable))
    {
    if ($row->pricedropenable == "yes")
      {
echo "<div id='home_popular_pricedrop'><a href='/product/$row->catid/$categreplace/$row->subid/$subcategreplace/$row->id/$titlereplace'>&#x25BC; PRICE DROP</a></div>";
      }
    }
          
      echo "<a href='/product/$row->catid/$categreplace/$row->subid/$subcategreplace/$row->id/$titlereplace'><img src='/images/productphotos/small/$row->photoprimary' alt='$row->title' />

<div class='home_popular_title'>$row->title ($count - $c)</div></a>
<div id='home_popular_base'>
      <div class='home_popular_stock'>";
      if ($row->preorder == "yes") { echo "pre-order only";}
      else if ($row->comingsoon == "yes") { echo "coming soon";}
      else
      { 
        echo "$row->rcstock";
      }
      echo "</div>
      
      <div class='home_popular_price'>";
      if ($row->pricedropenable == "yes") { echo "<font color='#ff0000'>&#x25BC;</font> Only &dollar;";
      printf ("%.2f", $row->price);
      echo "</font> Was <s>&dollar;";
      printf ("%.2f", $row->pricedrop);
      echo "</s>";
      }
      else 
      {	
      echo "Only ";
      printf ("$%.2f", $row->price);
      }
      echo "</div>
</div></div>";
  
  endwhile?>

  <!--page navigation-->
  <?php if (isset($next)): ?>
  <?php
  echo "<div class='nav'>
    <a href='/infinite-scroll?c=$c&p=";?><?php echo $next?>'>Next</a>
  </div>
  <?php endif?>
</div><!--.wrap-->
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: Automatic page adding more items, ajax pagination?

Post by simonmlewis »

I've cracked it - it was flipping stupid.
How did I not see this.

When I first started making this file, I used infinite-scroll.inc to test with.
Then used categ.inc to test it with the catid's.
What I failed to do what delete infinite-scroll.inc. so that link at the bottom was loading up that file in the next few rounds, which didn't have the IDs in them.

Job fixed!!
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: Automatic page adding more items, ajax pagination?

Post by simonmlewis »

How do I restrict how many it loads "in all"?
For example, I am having three pages of new products, so it's based on ID Desc. But need to show only, say, 100?

I doubt I put in LIMIT 0,100 coz that would mess up the other $limit factor.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Automatic page adding more items, ajax pagination?

Post by Celauran »

It loads triggerPageThreshold * items per page, so 4 pages of 25 or 5 pages of 20 should do what you want.
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: Automatic page adding more items, ajax pagination?

Post by simonmlewis »

No I need to use this script for categories, and new products. So it needs to be one script for all.
But in the DB script I need to tell it a max of 100 for example. CAn I not now do that, with the $limit code in there?
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: Automatic page adding more items, ajax pagination?

Post by simonmlewis »

I've figured it out. Restrict the "pages" bit for "next" at the foot of the page.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: Automatic page adding more items, ajax pagination?

Post by simonmlewis »

Can you spot anything I have done to stop this from returning more rows after the first 44?
It's usually the $next bit at the bottom of the code, with the url being wrong: categ/.
But that's the page that's loaded up.

This is on another site, but the JS file is the same, CSS same, and surrounding code is the same.
I've stripped back some of the scripts as they are not relevant to it, as in this slimmed down state, the problem remains (and is possibly easier for you to decipher a cause).

Code: Select all

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript" src="/js/infinite-scroll/jquery-ias.min.js"></script>
<script type="text/javascript">
  $(document).ready(function() {
    // Infinite Ajax Scroll configuration
    jQuery.ias({
      container : '.wrap', // main container where data goes to append
      item: '.home_popular', // single items
      pagination: '.nav', // page navigation
      next: '.nav a', // next page selector
      loader: '<img src="/js/infinite-scroll/ajax-loader.gif"/>', // loading gif
      triggerPageThreshold: 3 // show load more if scroll more than this
    });
  });
</script>
<link rel="stylesheet" media="all" href="/js/infinite-scroll/style.css">
<?php
require_once 'Mobile_Detect.php';
$detect = new Mobile_Detect;
include('dbconn.php');

$c = isset($_GET['c']) ? $_GET['c'] : null;
$query = ("SELECT categories FROM categories WHERE id =:c");
$result = $pdo->prepare($query);
$result->execute(array(':c' => $_GET['c']));
while ($row = $result->fetch(PDO::FETCH_OBJ)) 
      {
			echo "</div><div class='cat_head'><h1>$row->categories</h1></div>";
}


$query = ("SELECT * FROM categories WHERE id = :c AND introtext <> ''");
$result = $pdo->prepare($query);
$result->execute(array(':c' => $_GET['c']));

if (isset($_SESSION["loggedin"])) 
            {
            $usertype = $_SESSION["usertype"];
            if ($usertype == "admin")
              {
$num_rows = $result->rowCount();	
if ($num_rows == 0)
{
echo "<div class='cat_adminlink' style='float: left'><a href='/index.php?page=a_catbanners&ctype=cat&id=$c&p=y'><i class='fa fa-pencil-square-o'></i> Edit/Add Text</a></div>";
}
}
}
while ($row = $result->fetch(PDO::FETCH_OBJ)) 
      {
      echo "<div class='category_intro'>";

if (isset($_SESSION["loggedin"])) 
            {
            $usertype = $_SESSION["usertype"];
            if ($usertype == "admin")
              {
             echo "<div class='cat_adminlink'><a href='/index.php?page=a_catbanners&ctype=cat&id=$c&p=y'><i class='fa fa-pencil-square-o'></i> Edit/Add Text</a></div>";
             }
             }      
      
      echo "$row->introtext</div>";
      }
      
      
      echo "<div style='clear: both' /></div>";
      
      
      
$query = ("SELECT * FROM categorybanners WHERE catid =:c");
$result = $pdo->prepare($query);
$result->execute(array(':c' => $_GET['c']));
$num_rows = $result->rowCount();
if ($num_rows != 0)
{
 while ($row = $result->fetch(PDO::FETCH_OBJ)) 
      {
    echo "<div class='categ_topbanner'><a href='$row->url' style='text-decoration: none'><img src='/images/pages/$row->image' border='0'/></a>
    </div>
    <div class='categ_topbanner_text'>$row->cattext</div>";
    }
}	
echo "<div class='categ_topbox'><div class='categ_subbox'>";
$count = 0;
$query = "SELECT subname, subid, catname FROM products WHERE catid = :c AND pause = 'off' GROUP BY subname";
$result = $pdo->prepare($query);
$result->execute(array(':c' => $_GET['c']));
while ($row = $result->fetch(PDO::FETCH_OBJ)) 
{ 
 $subcateg = "$row->subname"; 
 $findsubcateg ="/ /"; 
 $replacesubcateg ="-"; 
 $subcategreplace = preg_replace ($findsubcateg, $replacesubcateg, $subcateg); 

 $categ = "$row->catname"; 
 $findcateg ="/ /"; 
 $replacecateg ="-"; 
 $categreplace = preg_replace ($findcateg, $replacecateg, $categ);  
 
echo "<div class='categ_subcateg'><a href='/subcateg/$c/$categreplace/$row->subid/$subcategreplace/'>$row->subname</a></div>";
}
echo "</div>";	

if (isset($_REQUEST['order'])) {
    $order = $_REQUEST['order'];
    $_SESSION['order'] = $_REQUEST['order'];
} else if (isset($_SESSION['order'])) {
    $order = $_SESSION['order'];
}

if(empty($_REQUEST['order']))
{ $order = "subname ASC";}

echo "<div class='categ_sortbox'><div class='";
if(isset($order))
{
if ($order == "title ASC") { echo "categ_subcategon";}
else
{
echo "categ_subcateg";
}
}
echo "'><a href='/categ/$c/$categreplace&order=title ASC' style='text-decoration: none'>A-Z</a></div>";

echo "<div class='";
if(isset($order))
{
if ($order == "title DESC") { echo "categ_subcategon";}
else
{
echo "categ_subcateg";
}
}
echo "'><a href='/categ/$c/$categreplace&order=title DESC' style='text-decoration: none'>Z-A</a></div>

<div class='";
if(isset($order))
{
if ($order == "price ASC") { echo "categ_subcategon";}
else
{
echo "categ_subcateg";
}
}

echo "'><a href='/categ/$c/$categreplace&order=price ASC' style='text-decoration: none'>Price (Low-High)</a></div>

<div class='";
if(isset($order))
{
if ($order == "price DESC") { echo "categ_subcategon";}
else
{
echo "categ_subcateg";
}
}
echo "'><a href='/categ/$c/$categreplace&order=price DESC' style='text-decoration: none'> (High-Low)</a></div>
</div><div style='clear: both; width: 500px'/></div></div><br/><div class='mainbodybox'>";
  
if ( $detect->isMobile() && !$detect->isTablet() ) {
$limit = 30; #item per page
}
else
{
$limit = 44; #item per page
}

$page = (int) (!isset($_GET['p'])) ? 1 : $_GET['p'];
# sql query
$result = "SELECT * FROM products WHERE catid = :c AND pause = 'off' ORDER BY rcstock = 'in stock' DESC,  rcstock = '' DESC, comingsoon = 'yes', rcstock = 'out of stock',  $order";
$sql = $pdo->prepare($result);
$sql->execute(array(':c' => $_GET['c']));
$num_rows = $sql->rowCount();
# find out query stat point
$start = ($page * $limit) - $limit;
# query for page navigation
if(($num_rows) > ($page * $limit) ){
  $next = ++$page;

}
$num_rows = 0;
  $count = 0;
$query = $result . " LIMIT $start, $limit";
$sql = $pdo->prepare($query);
$sql->execute(array(':c' => $_GET['c']));
$num_rows = $sql->rowCount();
if ($num_rows < 1) {
    header("HTTP/1.1 404 Not Found", true, 404);
    include ("custom_404.php");
    exit();
}
?>
<div class="wrap">

  <!-- loop row data -->
  <?php while ($row = $sql->fetch(PDO::FETCH_OBJ)):
  $count ++;
  $pricedrop = NULL;
	$backinstock = NULL;
  $checkBackinstock = NULL;
  $todaydate = date('Y-m-d');
  $newdate = strtotime("$todaydate");
  $dateenduse = strtotime("$row->datepricedrop");
  $datebackinstock = strtotime("$row->datebackinstock");
  
  $i=30;
  $checkBackinstock = strtotime(date("Y-m-d", strtotime($row->datebackinstock)) . " +".$i."days");

  $title = "$row->title"; 
  $findtitle ="/ /"; 
  $replacetitle ="-"; 
  $titlereplace = preg_replace ($findtitle, $replacetitle, $title); 
  
  $categ = "$row->catname"; 
  $findcateg ="/ /"; 
  $replacecateg ="-"; 
  $categreplace = preg_replace ($findcateg, $replacecateg, $categ); 
  
  $subcateg = "$row->subname"; 
  $findsubcateg ="/ /"; 
  $replacesubcateg ="-"; 
  $subcategreplace = preg_replace ($findsubcateg, $replacesubcateg, $subcateg); 
 
 
      if ($checkBackinstock >= $newdate) { $backinstock = "enable";
      }
      
      if ($row->comingsoon != "yes")
      {
if ($row->pricedrop != '' && $newdate < $dateenduse) { $pricedrop = "enable";}
}
      echo "<div class='home_popular'";
      
      if (($count % 4) == 0)
      {
      echo "style=' margin-right: 0px'";
      }
      
      echo ">";

 
echo "<a href='/product/$row->catid/$categreplace/$row->subid/$subcategreplace/$row->id/$titlereplace' title='Look at the $row->title'>";

if (isset($row->bundleroman1) && $row->bundleroman1 != '')
{
if (isset($row->photoprimary) && $row->photoprimary != '')
{
echo "<img src='http://www.site.co.uk/images/productphotos/small/$row->photoprimary' alt='$row->title' />";
}
else
{
echo "<img src='http://www.site.co.uk/images/blank_bundle.jpg' alt='$row->title' />";
}
}
else
{
if ($row->photoprimary == "" || $row->photoprimary == NULL)
        {
        echo "<img src='/images/blank.jpg'>";
        }
        else
        {
        echo "<img src='/images/productphotos/small/$row->photoprimary'></a>";
        }
        }
echo "
      <div class='home_popular_title'>$row->title</div></a>
      <div id='home_popular_base'>
      <div class='home_popular_stock'>";

echo "</div>

</div></div>";
  
  endwhile?>

  <!--page navigation-->
  <?php if (isset($next)): ?>
  <?php
  echo "<div class='nav'>
    <a href='/categ?c=$c&order=$order&p=";?><?php echo $next?>'>Next</a>
  </div>
  <?php endif?>
</div><!--.wrap-->
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: Automatic page adding more items, ajax pagination?

Post by simonmlewis »

Sorted it.
We use a 301 module that does the 301s if categories aren't in use. But in the module I use a different variable for the category ID..... and that's what killed it.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: Automatic page adding more items, ajax pagination?

Post by simonmlewis »

What is the view with SEO for this type of Infinite Scrolling?
I'm hearing Pros and Cons of using JAvascript. Would be interested to hear people's results.

http://www.w3bees.com/2013/09/jquery-in ... mysql.html

This is the one we are using.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
Post Reply