Redirectionare gresita la link in paginare
Scris: Joi Apr 05, 2012
imi apare eroare cand dau pe 2,3,etc ma redirectioneaza gresit in browseru
Cod: Selectaţi tot
<?php
//MySQL Database Connect
include 'dbinfo.php';
$tbl_name="images"; //your table name
$adjacents = 3; // How many adjacent pages should be shown on each side?
$query = "SELECT COUNT(*) as num FROM $tbl_name";
$total_pages = mysql_fetch_array(mysql_query($query));
$total_pages = $total_pages[num];
$seotag = "hot-images"; //for pages seo links, the current one example: "hot-images-1.html"
$limit = 12; //how many items to show per page
$page = $_GET['page'];
if($page)
$start = ($page - 1) * $limit;
else
$start = 0;
$sql = "SELECT code FROM $tbl_name ORDER BY id DESC LIMIT $start, $limit";
$result = mysql_query($sql);
if ($page == 0) $page = 1;
$prev = $page - 1;
$next = $page + 1;
$lastpage = ceil($total_pages/$limit);
$lpm1 = $lastpage - 1;
$pagination = "";
if($lastpage > 1)
{
$pagination .= "<div class=\"pagination\">";
//previous button
if ($page > 1)
$pagination.= "<a href=\"$seotag-$prev.html\">← previous</a>";
else
$pagination.= "<span class=\"disabled\">← previous</span>";
if ($lastpage < 7 + ($adjacents * 2))
{
for ($counter = 1; $counter <= $lastpage; $counter++)
{
if ($counter == $page)
$pagination.= "<span class=\"current\">$counter</span>";
else
$pagination.= "<a href=\"$seotag-$counter.html\">$counter</a>";
}
}
elseif($lastpage > 5 + ($adjacents * 2))
{
if($page < 1 + ($adjacents * 2))
{
for ($counter = 1; $counter < 4 + ($adjacents * 2); $counter++)
{
if ($counter == $page)
$pagination.= "<span class=\"current\">$counter</span>";
else
$pagination.= "<a href=\"$seotag-$counter.html\">$counter</a>";
}
$pagination.= "...";
$pagination.= "<a href=\"$seotag-$lpm1.html\">$lpm1</a>";
$pagination.= "<a href=\"$seotag-$lastpage.html\">$lastpage</a>";
}
elseif($lastpage - ($adjacents * 2) > $page && $page > ($adjacents * 2))
{
$pagination.= "<a href=\"$seotag-1.html\">1</a>";
$pagination.= "<a href=\"$seotag-2.html\">2</a>";
$pagination.= "...";
for ($counter = $page - $adjacents; $counter <= $page + $adjacents; $counter++)
{
if ($counter == $page)
$pagination.= "<span class=\"current\">$counter</span>";
else
$pagination.= "<a href=\"$seotag-$counter.html\">$counter</a>";
}
$pagination.= "...";
$pagination.= "<a href=\"$seotag-$lpm1.html\">$lpm1</a>";
$pagination.= "<a href=\"$seotag-$lastpage.html\">$lastpage</a>";
}
else
{
$pagination.= "<a href=\"$seotag-1.html\">1</a>";
$pagination.= "<a href=\"$seotag-2.html\">2</a>";
$pagination.= "...";
for ($counter = $lastpage - (2 + ($adjacents * 2)); $counter <= $lastpage; $counter++)
{
if ($counter == $page)
$pagination.= "<span class=\"current\">$counter</span>";
else
$pagination.= "<a href=\"$seotag-$counter.html\">$counter</a>";
}
}
}
//next button
if ($page < $counter - 1)
$pagination.= "<a href=\"$seotag-$next.html\">next →</a>";
else
$pagination.= "<span class=\"disabled\">next →</span>";
$pagination.= "</div>\n";
}
?>
<?php include 'header.php'; ?>
<div class="wide_content">
<h2 class="cf">Hot Gallery</h2>
<div class="cftext">
very hot one!
</div>
<p class="main_text">
All the picture are in HD! click on pictures to view full size.
</p>
<br />
<center>
<a href=http://getiton.com/go/g1140477-ppc?lang=english target="_blank" title="Click here for more."><img src="http://graphics.pop6.com/banners/getiton/english/25868_728x90.jpg" width="728" height="90" border="0" alt="Click here for more." /></a>
</center>
<div class="portofolio">
<ul class="item">
<?php
while($row = mysql_fetch_array($result))
{
echo '<li rel="webdesign">
<span class="clip"><img src="images/clip.png" alt="" border="0"/></span>
<br />
<div class="project_thumb">
'.$row["code"].'
</div>
</li>';
}
?>
</ul>
</div><!-- end of portofolio-->
</div> <!--end of wide content-->
<div class="clear"></div>
</div> <!--end of main_content-->
<center><?=$pagination?></center>
</div><!--end of main_container-->
<?php include 'footer.php'; ?>