Ver Mensaje Individual
  #1 (permalink)  
Antiguo 01/09/2008, 13:55
Avatar de hackteam
hackteam
 
Fecha de Ingreso: diciembre-2007
Mensajes: 67
Antigüedad: 16 años, 4 meses
Puntos: 0
Ayuda con paginacion por favor!!

hola, tengo este codigo y tengo un minisculo error que no puedo detectarlo! alguien puede darme una mano? gracias es para paginar los resultados de una consulta a una base de datos

Código PHP:
<?php
$Category 
$_GET['Category'];
$SEO_Title "$Category wallpapers";
$SEO_Description "Download the best $Category wallpapers FREE. We provide 800x600 and 1280x1024 sized images.";
$SEO_Keywords "wallpaper, wallpapers, naruto, free, ".$Category;
$SEO_H1 "Free $Category wallpapers.";

if (!isset(
$_GET['page'])) {
    
$image_path="../..";
    
$page_isset="";
} else {
    
$image_path ="../../..";
    
$page_isset="../";
}

include_once(
"skin.php");
echo 
$header;
echo 
"<h2>$Category wallpapers</h2>";

/*
    START THE PAGINATION FEATURE
    Available since version 1.2
*/

echo '
<style type="text/css">
.pagelink
{
    background: #E7EDF9;
    border: 1px solid #032390;
    padding: 0px 2px 0px 2px;
}
.tpagelink
{
    background: #FFC9A5;
    border: 1px solid #032390;
    padding: 0px 2px 0px 2px;
}
</style>
'
;

$page=$_GET['page'];
$limit=$Settings['Cat_Navigation_Count'];
if (
$page==NULL) {
    
$page=1;
}
$max_show=10;

$limitvalue $page $limit - ($limit);

$cCategory str_replace("+"" "$Category);
$cQuery "SELECT * FROM `Categories` WHERE `name`='$cCategory' LIMIT 1";
$cResult mysql_query($cQuery) or die(mysql_error());

if (
mysql_num_rows($cResult) <= 0)
{
    
$display_pagination=0;
} else
{
    
$query_count    "SELECT * FROM `Wallpapers` WHERE (`Category` = (SELECT `id` FROM `Categories` WHERE `name`='$cCategory') OR `Category` IN (SELECT `id` FROM `Categories` WHERE `Parent` = (SELECT `id` FROM `Categories` WHERE `name`='$cCategory'))) AND `approved` = '0' ORDER BY `ID` DESC";
    
$result_count   mysql_query($query_count);    
    
$totalrows      mysql_num_rows($result_count);
    if (
$totalrows==0) { $display_pagination 0; } else { $display_pagination 1; }
}

$numofpages = ($totalrows $limit); 

if (
$numofpages==1) { $display_pagination=0; }

if (
$page 3) {
    
$start=$page-2;
    
$end=$page+2;
    if (
$page==$numofpages) {
        
$end=$page;
        
$start=$start-2;
    } elseif (
$page+1==$numofpages) {
        
$end=$page+1;
        
$start=$start-1;
    }
} else {
    
$start=1;
    
$end=5;
}

if (
$page>=4) {
    
$apagenav='<span class="pagelink"><a href="'.$page_isset.'1/">«</a></span> ';
} else {
    
$apagenav='<span class="pagelink">«</span> ';
}

if (
$page $numofpages) {
    
$aend=' <span class="pagelink"><a href="'.$page_isset.$numofpages.'/">»</a></span>';
} else {
    
$aend=' <span class="pagelink">»</span>';
}


    for(
$i $start$i <= $end$i++){
        if(
$i == $page){
            
$apagenav .= '<span class="tpagelink">'.$i."</span> ";
        }else{
            
$apagenav .= '<span class="pagelink"><a href="'.$page_isset.''.$i.'/">'.$i.'</a></span> ';
        }
    }
    
$apagenav.=$aend;

    if (
$display_pagination==0) {
        
$apagenav=NULL;
    }

/*
    END THE PAGINATION FEATURE
    Available since version 1.2
*/

if ($image_path == "")
{
    
$image_path=$_SERVER['REQUEST_URI'];
}

if (
substr($image_path,strlen($image_path)-1,1) != "/")
    
$image_path=$image_path."/";

//Category wallpapers.
#get the category ID
if (mysql_num_rows($cResult) <= 0)
{
    echo 
"There are currently no wallpapers in this category.<br /><br />";
} else
{
    
$Row mysql_fetch_object($cResult);
    
$id $Row->id;

    
$query="SELECT * FROM `Wallpapers` WHERE (`Category` = '".$id."' OR `Category` IN (SELECT `id` FROM `Categories` WHERE `Parent` = '".$id."') AND `approved` = '0') AND `approved`='0' ORDER BY `ID` DESC LIMIT $limitvalue, $limit";
    
$result mysql_query($query);
    
$x 0;
    if (
mysql_num_rows($result) == 0)
    {
        echo 
"There are currently no wallpapers in this category.<br /><br />";
    } else
    {
        while (
$row mysql_fetch_assoc($result)) {
            
$x += 1;
            echo 
"\n".'<div class="Box Left">'."\n\t";
                echo 
'<div style="font-size: 1em; margin-bottom: 5px;"><a href="'.$image_path.'wallpaper/'.str_replace(" ""-"$row['Title']).'/">'.$row['Title']."</a></div>";
                echo 
'<a href="'.$image_path.'wallpaper/'.str_replace(" ""-"$row['Title']).'/"><img class="Thumbnail" src="'.$image_path.'images/wallpapers/'.$row['Thumbnail'].'" alt="'.$row['Name'].'" /></a>';
                echo 
'<div class="Clear"></div>'."\n";
            echo 
'</div>';
            if (!
is_int($x/3)){
                echo 
'<div class="Spacer">&nbsp;</div>';
            }
        }
    }
}

echo 
'<div class="Clear"></div>';
echo 
'<div><center>'.$apagenav.'</center></div>';

echo 
$footer;
?>
El error que me tira el servidor es este

Código:
Warning: Division by zero in /home/descarga/public_html/categories.php on line 66

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/descarga/public_html/categories.php on line 137
There are currently no wallpapers in this category.
no entiendo que esta mal, lo reviso y reviso y nos :( alguna ayuda por favor