Jump to content

Recommended Posts

Hi guy I am trying to get the pagination right. this is my code

<?php
echo"<img src='images/banner/ribbon.jpg' align='center' width='500' height='100' alt=''/>";
$categoria_id = $_GET['cat'];
 $query = "Select count(categoria_id) from categoria where categoria_id = $categoria_id";
 $result = mysql_query($query);
 $row = mysql_fetch_array($result);
 if (mysql_num_rows($result) > 0) {

 $per_page = 7;

 $pages_query = mysql_query("SELECT COUNT(nombre) from productos WHERE categoria_id=$categoria_id");
 $pages = ceil (mysql_result($pages_query, 0)/$per_page) ;

 $page = (isset($_GET['page'])) ? (int)$_GET['page']: 1;

 $start = ($page - 1) * $per_page;


$sql = mysql_query("SELECT * from productos WHERE categoria_id=$categoria_id LIMIT $start, $per_page");

while($row = mysql_fetch_array($sql)){
 $nombre = $row['nombre'];
 $descripcion = $row['descripcion'];
 $precio = $row['precio'];
 $imagen = $row['imagen'];
echo"<ul class=leaders>";
echo"<li><span><a href='images/platos/$imagen.jpg' rel='prettyPhoto[gallery4]' title='$nombre $descripcion' width='489' height='720'><img src='images/platos/$imagen.jpg' rel='prettyPhoto[gallery3]' align='left' width='105' height='90' alt=''/><strong>  $nombre</strong></a></span>";
echo"<span>$ $precio</span></li>";
echo"</ul>";
}
if($pages >=1 && $page <= $pages) {
for ($x =1; $x<=$pages; $x++) {
 echo ($x == $page) ? '<strong><a href="?page='.$x.'">'.$x.'</a></strong> ': '<a href="?page='.$x.'">'.$x.'</a> ';
}

}
}
?>

 

post-132281-0-86005700-1352249142_thumb.jpg

 

the problem is that when I click for example page number two in the pagination it shows me the index page... How I FIXT IT...

OH something else... how i erase the <li> dots?? I am trying with css but with not results.

THANKS IN ADVANCED

Edited by williamh26
Link to comment
https://forums.phpfreaks.com/topic/270383-pagination/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.