Ver Mensaje Individual
  #1 (permalink)  
Antiguo 22/04/2005, 16:30
raml
 
Fecha de Ingreso: abril-2005
Mensajes: 50
Antigüedad: 19 años
Puntos: 0
Pregunta Limitar resultados por pagina

Hola, estoy tratando de hacer que solo aparezcan 3 resultados por pagina de los registros que tengo en mi base de datos. Los siguientes registros deberían poder verse con el uso de dos links "Next Page" y otro "Previous Page".

Sin embargo, aunque si se ven 3 resultados de inicio, no he podido conseguir que el link "Next Page" funcione para ver los siguientes 3 registros, ojalá alguien pueda identificar el error en el script.

Saludos y Gracias

Código PHP:
<html>
<head>
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
//-->
</script>
<basefont face="Verdana">
</head>

<body>

<!-- standard page header begins -->
<p><p>

<table width="100%" cellspacing="0" cellpadding="5">
<tr>
    <td></td>
</tr>
<tr>
    <td bgcolor="Navy"><font size="-1" color="White">
    <b>Megalomaniacs Inc : Press Releases</b></font>
    </td>
</tr>
</table>
<!-- standard page header ends -->

<ul>
<?php

// numero de registros por página

$records_per_page 3;

// look for starting marker
//if not available, assume 0

(!$_GET['start']) ? $start $start $_GET['start'];

// includes (se conectan a la base de datos)

include('../conf.php');
include(
'../functions.php');
include(
'../diseno/conectarbd.php');

// generate and execute query

$query "SELECT COUNT(*) FROM documentos";
$result mysql_query($query) or die ("Error in query: $query. " mysql_error());

// get total number of records

$row mysql_fetch_row($result);
$total_records $row[0];

// if records present
if (($total_records 0) && ($start $total_records))
{

$query "SELECT id, titulo FROM documentos LIMIT $start, $records_per_page";

$result mysql_query($query) or die ("Error in query: $query. " mysql_error());

    
// iterate through resultset
    // print article titles
    // abrir las noticias como pop up window
    
while($row mysql_fetch_object($result))
    {
    
$id $row->id;
    
?>
        <li><font size="-1"><b>
        
        <a href="#self" onClick="MM_openBrWindow('story.php?id=<?php echo $id?>','','toolbar=yes,status=yes,scrollbars=yes,resizable=yes,width=650,height=550')"><?php echo $row->titulo?></a></b></font><br>
        
        <font size="-2"><?php echo formatDate($row->timestamp); ?>
        </font>
        <p>
        
    <?php
    
}

// Set up the "previous page" link
// this should appear on all pages except the first page
//the start point for the previous page will be the start point for this page less the number of records per page

if ($start >= $records_per_page)
{
    echo 
"<a href=" $_SERVER['PHP_SELF'] . "?start=" . ($start-$records_per_page) . ">Previous Page</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
}

// Set up the "next page" link
// this should appear on all pages except the last page
//the start point for the next page will be the end point for this page

if ($start+$records_per_page $total_records && $start >= 0)
{
    echo 
"<a href=" $_SERVER['PHP_SELF'] . "?start=" . ($start+$records_per_page) . ">Next Page</a>";
}

}

// if no records present
// display message
else
{
?>
    <font size="-1">No press releases currently available</font>
<?php
}

// close database connection
mysql_close($connection);
?>

<br>

<P>&nbsp;</P>

<a href="../admin/list.php">Admin Page </a>    
        </ul>

<!-- standard page footer begins -->
<p>
<table width="100%" cellspacing="0" cellpadding="5">
<tr>
    <td align="center"><font size="-2">
    All rights reserved. Visit Melonfire 
    <a href="http://www.melonfire.com/community/columns/trog/"> 
    here</a> for <a href="#" onClick="MM_openBrWindow('story.php','','toolbar=yes,status=yes,scrollbars=yes,resizable=yes,width=650,height=550')">more</a>.</td>
</tr>
</table>
<!-- standard page footer ends -->

</body>
</html>