Imprimir
Marco de El Alma Hispana Marco de El Alma Hispana

Refranes

include '../admin/config.php'; include '../admin/opendb.php'; // how many rows to show per page $rowsPerPage = 20; // by default we show first page $pageNum = 1; // if $_GET['page'] defined, use it as page number if(isset($_GET['page'])) { $pageNum = $_GET['page']; } // counting the offset $offset = ($pageNum - 1) * $rowsPerPage; $query = "SELECT ref_ID, refran FROM Refranes ORDER BY refran ASC LIMIT $offset, $rowsPerPage"; $result = mysql_query($query) or die('Error, query falla'); // print the random numbers while(list($ref_ID,$refran) = mysql_fetch_array($result)) { If ($bgcolorswitch == "0") { $bgcolorswitch = "1"; $bgcolor = "#FFFFFF"; } Else { $bgcolorswitch = "0"; $bgcolor = "#EEEEEE"; } echo ""; echo ""; echo ""; } echo '
$refran


'; // how many rows we have in database $query = "SELECT COUNT(ref_ID) AS numrows FROM Refranes"; $result = mysql_query($query) or die('Error, query failed'); $row = mysql_fetch_array($result, MYSQL_ASSOC); $numrows = $row['numrows']; // how many pages we have when using paging? $maxPage = ceil($numrows/$rowsPerPage); $self = $_SERVER['PHP_SELF']; // creating 'previous' and 'next' link // plus 'first page' and 'last page' link // print 'previous' link only if we're not // on page one if ($pageNum > 1) { $page = $pageNum - 1; $prev = " "; $first = " « "; } else { $prev = ' ‹ '; // we're on page one, don't enable 'previous' link $first = ' « '; // nor 'first page' link } // print 'next' link only if we're not // on the last page if ($pageNum < $maxPage) { $page = $pageNum + 1; $next = " "; $last = " » "; } else { $next = ' › '; // we're on the last page, don't enable 'next' link $last = ' » '; // nor 'last page' link } // print the page navigation link echo "
" . $first . $prev . " Página $pageNum de $maxPage " . $next . $last . "
"; // and close the database connection mysql_close($conn); // ... and we're done! ?>
Marco de El Alma Hispana Marco de El Alma Hispana
El Alma Hispana

Refranes

include '../admin/config.php'; include '../admin/opendb.php'; // how many rows to show per page $rowsPerPage = 20; // by default we show first page $pageNum = 1; // if $_GET['page'] defined, use it as page number if(isset($_GET['page'])) { $pageNum = $_GET['page']; } // counting the offset $offset = ($pageNum - 1) * $rowsPerPage; $query = "SELECT ref_ID, refran FROM Refranes ORDER BY refran ASC LIMIT $offset, $rowsPerPage"; $result = mysql_query($query) or die('Error, query falla'); // print the random numbers while(list($ref_ID,$refran) = mysql_fetch_array($result)) { If ($bgcolorswitch == "0") { $bgcolorswitch = "1"; $bgcolor = "#FFFFFF"; } Else { $bgcolorswitch = "0"; $bgcolor = "#EEEEEE"; } echo ""; echo ""; echo ""; } echo '
$refran


'; // how many rows we have in database $query = "SELECT COUNT(ref_ID) AS numrows FROM Refranes"; $result = mysql_query($query) or die('Error, query failed'); $row = mysql_fetch_array($result, MYSQL_ASSOC); $numrows = $row['numrows']; // how many pages we have when using paging? $maxPage = ceil($numrows/$rowsPerPage); $self = $_SERVER['PHP_SELF']; // creating 'previous' and 'next' link // plus 'first page' and 'last page' link // print 'previous' link only if we're not // on page one if ($pageNum > 1) { $page = $pageNum - 1; $prev = " "; $first = " « "; } else { $prev = ' ‹ '; // we're on page one, don't enable 'previous' link $first = ' « '; // nor 'first page' link } // print 'next' link only if we're not // on the last page if ($pageNum < $maxPage) { $page = $pageNum + 1; $next = " "; $last = " » "; } else { $next = ' › '; // we're on the last page, don't enable 'next' link $last = ' » '; // nor 'last page' link } // print the page navigation link echo "
" . $first . $prev . " Página $pageNum de $maxPage " . $next . $last . "
"; // and close the database connection mysql_close($conn); // ... and we're done! ?>