php - Pagination for product listing pages -
i building shop taking products txt file , want create pagination product listing pages.
the code using pull products , display them is:
<?php // local file $p = file_get_contents('mytxtfile.txt'); // turn file array, line line $ar = explode("\n",$p); // setup count how many products there $found = 0; // loop through products for($i = 0; $i < count($ar); $i++){ $product = explode("|",$ar[$i]); if( (strpos(slug($product[9]),$_get['slug']) !== false ) || (strpos(slug($product[10]),$_get['slug']) !== false ) || (strpos(slug($product[21]),$_get['slug']) !== false ) ){ // product numbers below correspond column number in csv $found++; // increment number of files found echo '<div class="item">'; echo '<a href="/'.slug($product[21]).'/'.slug($product[1]).'.htm"><img src="'.$product[5].'" /></a>'; echo '<h3><a href="/'.slug($product[21]).'/'.slug($product[1]).'.htm">'.substr($product[1], 0, 70).'</a></h3>'; if (slug($product[8]) == slug($product[7])){ echo '<p class="price">only $'.($product[7]).'</p>'; } else { echo '<p class="price"><del>was $'.($product[8]).'</del> $'.($product[7]).'</p>'; } echo '</div>'; if($found > 101){ break; } } } ?>
this display products upto break want show products. categories have lot of products , want keep page load time down.
use jquery plugin datatables mysql. stated above glasseye valid.
Comments
Post a Comment