Core: Muchas gracias por tu ayuda!
FuLaNo_ : Exelente el TIP, funciona muy bien es mas sencillo asi.
aunque ya "funciona" tengo un problema con el codigo es es mi codigo original que funciona perfecto:
Código PHP:
<table width="98%" border="1" cellpadding="3" cellspacing="0">
<?php
do {
?>
<tr>
<td><?php echo $row_rs_countries['Surname']; ?></td>
<td><a href="instructores_update.php?ID=<?php echo $row_rs_countries['ID']; ?>">Modify this country's profile</a></td>
<td><a href="delete_processor.php?ID=<?php echo $row_rs_countries['ID']; ?>">Delete</a></td>
</tr>
<?php
}
while ($row_rs_countries = mysql_fetch_assoc($rs_countries));
?>
</table>
al darme cuenta que este codigo
me bota miles de entradas de MYSQL trato de hacer una paginacion osea que me despliegue 300 entradas por pagina ahora mi problema es que me hace 11 paginas con el mismo contenido
![Neurótico](http://static.forosdelweb.com/fdwtheme/images/smilies/scared.png)
alguna idea de como lo soluciono ?
En la linea donde esta Fulano (comentario en el codigo) esta el codigo que me ayudaron a cambiar y es donde radicaria el problema. Código PHP:
<?php require_once('../../Connections/conn_newland.php'); ?>
<?php
mysql_select_db($database_conn_newland, $conn_newland);
$query_rs_countries = "SELECT ID, Surname FROM tbl_instructores ORDER BY Surname ASC";
$rs_countries = mysql_query($query_rs_countries);
$row_rs_countries = mysql_fetch_assoc($rs_countries);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>
<body>
<?php
// Database Connection
mysql_select_db('newland_tours', mysql_pconnect('localhost','root','root')) or die (mysql_error());
// If current page number, use it
// if not, set one!
if(!isset($_GET['page'])){
$page = 1;
} else {
$page = $_GET['page'];
}
// Define the number of results per page
$max_results = 10;
// Figure out the limit for the query based
// on the current page number.
$from = (($page * $max_results) - $max_results);
// Perform MySQL query on only the current page number's results
$sql = mysql_query("SELECT * FROM tbl_instructores LIMIT $from, $max_results");
while($row = mysql_fetch_array($sql)){
do {
// Ayuda de FULANO
echo $row_rs_countries["Surname"]. " ID: " . $row_rs_countries['ID'] . ' <a href="instructores_update.php?ID='.$row_rs_countries["ID"].'">Modify this countrys profile</a> '. "<br />";
}
while ($row_rs_countries = mysql_fetch_assoc($rs_countries));
}
// Figure out the total number of results in DB:
$total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM tbl_instructores"),0);
// Figure out the total number of pages. Always round up using ceil()
$total_pages = ceil($total_results / $max_results);
// Build Page Number Hyperlinks
echo "<center>Select a Page<br />";
// Build Previous Link
if($page > 1){
$prev = ($page - 1);
echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$prev\"><<Previous</a> ";
}
for($i = 1; $i <= $total_pages; $i++){
if(($page) == $i){
echo "$i ";
} else {
echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$i\">$i</a> ";
}
}
// Build Next Link
if($page < $total_pages){
$next = ($page + 1);
echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$next\">Next>></a>";
}
echo "</center>";
?>
Alright, it looks like I have some explaining to do! Let's break the code
</body>
</html>