Tema: Paginar
Ver Mensaje Individual
  #7 (permalink)  
Antiguo 30/09/2008, 13:40
kireta
 
Fecha de Ingreso: agosto-2008
Mensajes: 54
Antigüedad: 16 años, 3 meses
Puntos: 0
Pregunta Respuesta: Paginar

Cita:
Que ta kireta, sin ver el código que utilizas actualmente será muy facil entender en que falla, publica el código...
Hola, bueno, nuevamente gracias por responder, eh?
Para responderte, esto es lo que me pasa:

Tengo este codigo que realiza una busqueda:
Código:
<html>

<body>

<form method="POST" action="buscador.php3">

<strong>Quiero buscar a:</strong>

<input type="text" name="buscar" size="20"><br><br>

<input type="submit" value="¡ A Buscar !">

</form>

</body>

</html>
que funciona en conjunto con éste:
Código:
 <?php require_once('Connections/postgrados.php'); ?>


<html>
<head>

 <?php
$currentPage = $_SERVER["PHP_SELF"];

$maxRows_Recordset2 = 1;
$pageNum_Recordset2 = 0;
if (isset($_GET['pageNum_Recordset2'])) {
  $pageNum_Recordset2 = $_GET['pageNum_Recordset2'];
}
$startRow_Recordset2 = $pageNum_Recordset2 * $maxRows_Recordset2;

mysql_select_db($database_postgrados, $postgrados);

$query_Recordset2 = "SELECT * FROM estudiante WHERE apellido LIKE '%$buscar%' or nombre LIKE '%$buscar%' or especializacion LIKE '%$buscar%' or rango LIKE '%$buscar%' or ciudadcasa LIKE '%$buscar%' or empresa LIKE '%$buscar%' or ciudadjob LIKE '%$buscar%' or cargo LIKE '%$buscar%' or usuario LIKE '%$buscar%' ORDER BY apellido";

$query_limit_Recordset2 = sprintf("%s LIMIT %d, %d", $query_Recordset2, $startRow_Recordset2, $maxRows_Recordset2);
$Recordset2 = mysql_query($query_limit_Recordset2, $postgrados) or die(mysql_error());
$row_Recordset2 = mysql_fetch_assoc($Recordset2);

if (isset($_GET['totalRows_Recordset2'])) {
  $totalRows_Recordset2 = $_GET['totalRows_Recordset2'];
} else {
  $all_Recordset2 = mysql_query($query_Recordset2);
  $totalRows_Recordset2 = mysql_num_rows($all_Recordset2);
}
$totalPages_Recordset2 = ceil($totalRows_Recordset2/$maxRows_Recordset2)-1;

$queryString_Recordset2 = "";
if (!empty($_SERVER['QUERY_STRING'])) {
  $params = explode("&", $_SERVER['QUERY_STRING']);
  $newParams = array();
  foreach ($params as $param) {
    if (stristr($param, "pageNum_Recordset2") == false && 
        stristr($param, "totalRows_Recordset2") == false) {
      array_push($newParams, $param);
    }
  }
  if (count($newParams) != 0) {
    $queryString_Recordset2 = "&" . htmlentities(implode("&", $newParams));
  }
}
$queryString_Recordset2 = sprintf("&totalRows_Recordset2=%d%s", $totalRows_Recordset2, $queryString_Recordset2);
?>
</head>
<style type="text/css">
<!--
body,td,th {
	color: #FFFFFF;
}
body {
	background-color: #000000;
}
-->
</style>

<body> 

<?php 

if (!isset($buscar)){ 
echo "<p>Debe especificar </p>";
echo "<p><a href=formulario.php>Volver</p>"; 
echo "</html></body>"; 
exit; 

} 

$link = mysql_connect("localhost", "root","123456"); 

mysql_select_db("postgrados", $link); 

$sql = "SELECT * FROM estudiante WHERE apellido LIKE '%$buscar%' or nombre LIKE '%$buscar%' or especializacion LIKE '%$buscar%' or rango LIKE '%$buscar%' or ciudadcasa LIKE '%$buscar%' or empresa LIKE '%$buscar%' or ciudadjob LIKE '%$buscar%' or cargo LIKE '%$buscar%' or usuario LIKE '%$buscar%' ORDER BY apellido"; 

$result = mysql_query($sql, $link); 

if ($row = mysql_fetch_array($result)){ 


echo "<table border='1' align='left' cellpadding='1' cellspacing='1' bordercolor='#FFFFFF' bgcolor='#000000'>"; 


mysql_field_seek($result,0); 

while ($field = mysql_fetch_field($result))

do { 

echo "<tr>"; 
echo "<th>Apellido</th>"; 
echo "<th>:</th>"; 
echo "<th>".$row["apellido"]."</th>"; 
echo "<th>Nombre</th>"; 
echo "<th>:</th>"; 
echo "<th>".$row["nombre"]."</th>"; 
echo "</tr>";
echo "<tr>"; 
echo "<th>Cedula</th>"; 
echo "<th>:</th>"; 
echo "<td>".$row["cedula"]."</td>"; 
echo "<th>Codigo</th>"; 
echo "<th>:</th>"; 
echo "<td>".$row["codigo"]."</td>"; 
echo "</tr>";
echo "<tr>"; 
echo "<th>Ragon</th>"; 
echo "<th>:</th>"; 
echo "<td>".$row["rango"]."</td>"; 
echo "<th>Especializacion</th>"; 
echo "<th>:</th>"; 
echo "<td>".$row["especializacion"]."</td>"; 
echo "</tr>";
echo "<tr>"; 
echo "<th>Ciudad Res</th>"; 
echo "<th>:</th>"; 
echo "<td>".$row["ciudadcasa"]."</td>"; 
echo "<th>Direccion Casa</th>"; 
echo "<th>:</th>"; 
echo "<td>".$row["dircasa"]."</td>"; 
echo "</tr>";
echo "<tr>"; 
echo "<th>Tel Casa</th>"; 
echo "<th>:</th>"; 
echo "<td>".$row["telcasa"]."</td>"; 
echo "<th>Celular 1</th>"; 
echo "<th>:</th>"; 
echo "<td>".$row["celular1"]."</td>"; 
echo "</tr>";
echo "<tr>"; 
echo "<th>Celular 2</th>"; 
echo "<th>:</th>"; 
echo "<td>".$row["celular2"]."</td>"; 
echo "<th>Email 1</th>"; 
echo "<th>:</th>"; 
echo "<td>".$row["email1"]."</td>"; 
echo "</tr>";
echo "<tr>"; 
echo "<th>Email 2</th>"; 
echo "<th>:</th>"; 
echo "<td>".$row["email2"]."</td>"; 
echo "<th>Empresa</th>"; 
echo "<th>:</th>"; 
echo "<td>".$row["empresa"]."</td>"; 
echo "</tr>";
echo "<tr>"; 
echo "<th>Ciudad Trabajo</th>"; 
echo "<th>:</th>"; 
echo "<td>".$row["ciudadjob"]."</td>"; 
echo "<th>Cargo Emp</th>"; 
echo "<th>:</th>"; 
echo "<td>".$row["cargo"]."</td>"; 
echo "</tr>";
echo "<tr>"; 
echo "<th>Tel Job</th>"; 
echo "<th>:</th>"; 
echo "<td>".$row["teljob"]."</td>"; 
echo "<th>Observacion</th>"; 
echo "<th>:</th>"; 
echo "<td>".$row["observacion"]."</td>"; 
echo "</tr>";
echo "<tr>"; 
echo "<th>Fecha Ingreso</th>"; 
echo "<th>:</th>"; 
echo "<td>".$row["ingresoyear"]."</td>"; 
echo "<th>Usuario</th>"; 
echo "<th>:</th>"; 
echo "<td>".$row["usuario"]."</td>"; 
echo "</tr>";
echo "<tr>"; 
echo "<th>Password</th>"; 
echo "<th>:</th>"; 
echo "<td>".$row["password"]."</td>"; 
echo "<th>Nivel Acceso</th>"; 
echo "<th>:</th>"; 
echo "<td>".$row["nivel"]."</td>"; 
echo "</tr>";


} 
while ($row = mysql_fetch_array($result)); 
while ($row_Recordset2 = mysql_fetch_assoc($Recordset2));
echo "<p><a href=formulario.php>Volver</p>"; 
echo "</table>"; 


} else { 

echo "<p>¡Cambie el campo a buscar!</p>"; 

echo "<p><a href=formulario.php>Volver</p>"; 

} 

?>



<a href="<?php printf("%s?pageNum_Recordset2=%d%s", $currentPage, max(0, $pageNum_Recordset2 - 1), $queryString_Recordset2); ?>"></a>
<table border="0" width="50%" align="LEFT">
  <tr>
    <td width="23%" align="center"><?php if ($pageNum_Recordset2 > 0) { // Show if not first page ?>
          <a href="<?php printf("%s?pageNum_Recordset2=%d%s", $currentPage, 0, $queryString_Recordset2); ?>"><img src="First.gif" border=0></a>
          <?php } // Show if not first page ?>
    </td>
    <td width="31%" align="center"><?php if ($pageNum_Recordset2 > 0) { // Show if not first page ?>
          <a href="<?php printf("%s?pageNum_Recordset2=%d%s", $currentPage, max(0, $pageNum_Recordset2 - 1), $queryString_Recordset2); ?>"><img src="Previous.gif" border=0></a>
          <?php } // Show if not first page ?>
    </td>
    <td width="23%" align="center">
	
	<?php if ($pageNum_Recordset2 < $totalPages_Recordset2) { // Show if not last page ?>
    <a href="<?php printf("%s?pageNum_Recordset2=%d%s", $currentPage, min($totalPages_Recordset2, $pageNum_Recordset2 + 1), $queryString_Recordset2); ?>"><img src="Next.gif" border=0></a>
          <?php } // Show if not last page ?>
    </td>
    <td width="23%" align="center"><?php if ($pageNum_Recordset2 < $totalPages_Recordset2) { // Show if not last page ?>
          <a href="<?php printf("%s?pageNum_Recordset2=%d%s", $currentPage, $totalPages_Recordset2, $queryString_Recordset2); ?>"><img src="Last.gif" border=0></a>
          <?php } // Show if not last page ?>
    </td>
  </tr>
</table>
<p><a href="main.html" target="_self"><img src="First.gif" alt="PRINCIPIO" border="0"/></a></p>
</body>

</html>
<?php
mysql_free_result($Recordset2);
?>
El problema es que ya le puse paginacion tal y como lo haria el dreamweaver por que hay que recordar que soy hasta este punto una noobie... newbie? entonces que hago mal en el segundo codigo?