Ver Mensaje Individual
  #3 (permalink)  
Antiguo 09/05/2007, 10:29
Avatar de mary86
mary86
 
Fecha de Ingreso: mayo-2007
Mensajes: 21
Antigüedad: 17 años
Puntos: 0
Re: problema para mostrar registros

esta es la tabla donde se muestran los registros , yo tengo una barra de navegacion(paginacion) debajo, yo necesito que cuando yo le de click en la sig pagina me muestre su contenido como habia dicho anteriormente solo muestra el contenido del primer registro, es decir necesito mostrar un registro por pagina y actualizar la inf de acuerdo a la paginacion


<table width="527" border="0" align="left">
<tr>
<td width="220" class="textoformulario"><div align="right" class="textoformulario">
<div align="right">Codigo de Usuario :</div>
</div></td>
<td width="291" class="textoformulario"><input name="txtcodusuario" type="text" class="input1" id="txtcodusuario" value="<?php echo $row_RsUsuarios['codusuario']; ?>"></td>
</tr>
<tr>
<td colspan="2" class="textoformulario"><img src="images/pix.gif" width="1" height="1"></td>
</tr>
<tr>
<td colspan="2" class="textoformulario"><img src="images/pix.gif" width="1" height="1"></td>
</tr>
<tr>
<td class="textoformulario"><div align="right">Nombres:</div></td>
<td class="textoformulario"><input name="txtnombres" type="text" class="input1" id="txtnombres" value="<?php echo $row_RsUsuarios['nombres']; ?>"></td>
</tr>
<tr>
<td colspan="2" class="textoformulario"><img src="images/pix.gif" width="1" height="1"></td>
</tr>
<tr>
<td class="textoformulario"><div align="right">Apellidos:</div></td>
<td class="textoformulario"><input name="txtapellidos" type="text" class="input1" id="txtapellidos" value="<?php echo $row_RsUsuarios['apellidos']; ?>"></td>
</tr>
<tr>
<td colspan="2" class="textoformulario"><img src="images/pix.gif" width="1" height="1"></td>
</tr>
<tr>
<td class="textoformulario"><div align="right">UserName:</div></td>
<td class="textoformulario"><input name="txtuser" type="text" class="input1" id="txtuser" value="<?php echo $row_RsUsuarios['username']; ?>"></td>
</tr>
<tr>
<td colspan="2" class="textoformulario"><img src="images/pix.gif" width="1" height="1"></td>
</tr>
<tr>
<td class="textoformulario"><div align="right">Password:</div></td>
<td class="textoformulario"><input name="txtpass" type="password" class="input1" id="txtpass" value="<?php echo $row_RsUsuarios['password']; ?>"></td>
</tr>
<tr>
<td colspan="2" class="textoformulario"><img src="images/pix.gif" width="1" height="1"></td>
</tr>
<tr>
<td class="textoformulario"><div align="right">Tipo de usuario:</div></td>
<td class="textoformulario"><input name="txttipouser" type="text" class="input1" id="txttipouser" value="<?php echo $row_RsUsuarios['tipousuario']; ?>"></td>
</tr>
</table>

y este es el codigo que pagina


<?php require_once('../../Connections/cn.php'); ?>
<?php
$currentPage = $_SERVER["PHP_SELF"];

function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;

switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
$updateSQL = sprintf("UPDATE usuarios SET nombres=%s, apellidos=%s, username=%s, password=%s, tipousuario=%s WHERE codusuario=%s",
GetSQLValueString($_POST['txtnombres'], "text"),
GetSQLValueString($_POST['txtapellidos'], "text"),
GetSQLValueString($_POST['txtuser'], "text"),
GetSQLValueString($_POST['txtpass'], "text"),
GetSQLValueString($_POST['txttipouser'], "text"),
GetSQLValueString($_POST['txtcodusuario'], "int"));

mysql_select_db($database_cn, $cn);
$Result1 = mysql_query($updateSQL, $cn) or die(mysql_error());
}

$maxRows_Rs_Usuarios = 1;
$pageNum_Rs_Usuarios = 0;
if (isset($_GET['pageNum_Rs_Usuarios'])) {
$pageNum_Rs_Usuarios = $_GET['pageNum_Rs_Usuarios'];
}
$startRow_Rs_Usuarios = $pageNum_Rs_Usuarios * $maxRows_Rs_Usuarios;

mysql_select_db($database_cn, $cn);
$query_Rs_Usuarios = "SELECT * FROM usuarios";
$query_limit_Rs_Usuarios = sprintf("%s LIMIT %d, %d", $query_Rs_Usuarios, $startRow_Rs_Usuarios, $maxRows_Rs_Usuarios);
$Rs_Usuarios = mysql_query($query_limit_Rs_Usuarios, $cn) or die(mysql_error());
$row_Rs_Usuarios = mysql_fetch_assoc($Rs_Usuarios);

if (isset($_GET['totalRows_Rs_Usuarios'])) {
$totalRows_Rs_Usuarios = $_GET['totalRows_Rs_Usuarios'];
} else {
$all_Rs_Usuarios = mysql_query($query_Rs_Usuarios);
$totalRows_Rs_Usuarios = mysql_num_rows($all_Rs_Usuarios);
}
$totalPages_Rs_Usuarios = ceil($totalRows_Rs_Usuarios/$maxRows_Rs_Usuarios)-1;

$queryString_Rs_Usuarios = "";
if (!empty($_SERVER['QUERY_STRING'])) {
$params = explode("&", $_SERVER['QUERY_STRING']);
$newParams = array();
foreach ($params as $param) {
if (stristr($param, "pageNum_Rs_Usuarios") == false &&
stristr($param, "totalRows_Rs_Usuarios") == false) {
array_push($newParams, $param);
}
}
if (count($newParams) != 0) {
$queryString_Rs_Usuarios = "&" . htmlentities(implode("&", $newParams));
}
}
$queryString_Rs_Usuarios = sprintf("&totalRows_Rs_Usuarios=%d%s", $totalRows_Rs_Usuarios, $queryString_Rs_Usuarios);
?>
<?php require_once('cn.php'); ?>
<?php
mysql_select_db($database_Cn, $Cn);
$RsUsuarios = mysql_query("select * FROM usuarios");
$row_RsUsuarios = mysql_fetch_assoc($RsUsuarios);
?>

luego simplemente escribo

Registro <?php echo ($startRow_Rs_Usuarios + 1) ?> de <?php echo $totalRows_Rs_Usuarios ?>