Hi guys, thanks for all your help. I am trying to use php pagination without mysqli on one of my pages and I have the following php script. however, it keeps outputting an error that $page is not indexed please help and also how to put a css style attribute to my arrays.
<?php
$array = array('Music and chairs','hello mama','c','d','e','f','g','h','i','j'); //failing to put styles on this info array
$total_data = count($array); // COUNTING TOTAL ARRAY
$per_page = 3;
// Outputting error on the $page below
$page = intval($_GET['page']); // Error output is this - Undefined index: page
if(empty($page) || $page==1) {
$start_val = 0;
$end_val = $per_page - 1;
}
else {
$start_val = ($page * $per_page) - $per_page;
$end_val = $start_val + ($per_page - 1);
}
//Echoing my array and failing to use my css
for($i=$start_val;$i<=$end_val;$i++){
echo $array[$i].' ';
}
$less_than = $total_data/$per_page;
if($less_than>intval($less_than)) $less_than = $less_than + 1;
if($total_data>1) {
echo '<div class="pagination">';
echo ($page-1)>0?'<a href="?page='.($page-1).'">Previous</a> ':'Previous ';
for($i=1;$i<=$less_than;$i++){
if($page==$i) echo '<a class="paginator linkno">';
else echo '<a href="?page='.$i.'" class="paginator">';
echo $i;
echo '</a> ';
}
echo ($page+1)<=$less_than?'<a href="?page='.($page+1).'">Next</a>':'Next';
echo '</div>';
}
?>