Reputation: 3
I have a problem with my pagination script. I have two links on one category:
link 1: abc.com/category.html
link 2: abc.com/category-p2.html
My php script is:
$pagelink = 'abc.com/category';
if($pages > 1)
{
$pagination = '';
$pagination.= '<ul class="paginate">';
for($i = 1; $i<=$pages; $i++)
{
$pagination .= '<li><a href="'.$pagelink.'-p'.$i.'.html">'.$i.'</a></li>';
}
$pagination .= '</ul>';
}
I want that: if $i=1, $pagelink is: abc.com/category, not add -p$i before html prefix. So my new code is:
$pagelink = 'abc.com/category';
if($pages > 1)
{
$pagination = '';
$pagination.= '<ul class="paginate">';
for($i = 1; $i<=$pages; $i++)
{
if($i=1)
{$pagination .= '<li><a href="'.$pagelink.'.html">1</a></li>';}
else
{$pagination .= '<li><a href="'.$pagelink.'-p'.$i.'.html">'.$i.'</a></li>';}
}
$pagination .= '</ul>';
}
But it's seem that it is not working. Please help me to fix this. Thanks alot in advance.
Upvotes: 0
Views: 84
Reputation: 2541
One immediate problem jumps out at me:
if($i=1)
should be:
if ($i == 1)
Upvotes: 2