PHP - Problema con página dinámica

 
Vista:

Problema con página dinámica

Publicado por Xavi (2 intervenciones) el 11/01/2009 12:34:19
Hola a tod@s, a ver si me podéis ayudar.

He creado una página con un formulario que envía el valor introducido en él a la base de datos. También he creado una tabla donde mostrar todos los datos recogidos con un enlace en cada registro para mostrar determinados datos Y aquí es donde viene el problema, la variable pasa bien a la página de recepción pero los datos impresos son siempre el correspondiente al primer registro.

Os dejo el enlace y el código de las dos paginas.

Muchas gracias de antemano. Saludos

http://xavi.eshost.com.ar/aaa.php

Formulario
<?php
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_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO ejercicio (ejercicio_usuario) VALUES (%s)",
GetSQLValueString($_POST['ejercicio_usuario'], "text"));

mysql_select_db($database_byxaby, $byxaby);
$Result1 = mysql_query($insertSQL, $byxaby) or die(mysql_error());
}

mysql_select_db($database_byxaby, $byxaby);
$query_Recordset1 = "SELECT * FROM ejercicio";
$Recordset1 = mysql_query($query_Recordset1, $byxaby) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>

Registros totales <?php echo $totalRows_Recordset1 ?>

<form name="form1" method="POST" action="<?php echo $editFormAction; ?>">
Introducir usuario:
<input name="ejercicio_usuario" type="text" id="ejercicio_usuario">
<input type="submit" name="Submit" value="Enviar">
<input type="hidden" name="MM_insert" value="form1">
</form>
<table width="70%" border="1" cellspacing="0" cellpadding="1">
<tr>
<td> </td>
<td> </td>
</tr>
<?php do { ?>
<tr>
<td><?php echo $row_Recordset1['ejercicio_usuario']; ?></td>
<td><a href="bbb.php?<?php echo $row_Recordset1['ejercicio_usuario']; ?>=">Ver</a></td>
</tr>
<?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
</table>

<?php
mysql_free_result($Recordset1);
?>

Recepción
<?php
mysql_select_db($database_byxaby, $byxaby);
$query_Recordset1 = "SELECT * FROM ejercicio";
$Recordset1 = mysql_query($query_Recordset1, $byxaby) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>

<?php echo urlencode($row_Recordset1['ejercicio_usuario']); ?></body>
</html>
<?php
mysql_free_result($Recordset1);
?>
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:Problema con página dinámica

Publicado por Xavi (2 intervenciones) el 12/01/2009 12:13:14
Ya lo he soluciono,
En el código del formulario fallaba el link. El código correcto es:

a href="bbb.php?bbb=<?php echo $row_Recordset1['ejercicio_pk']; ?>

Gracias de todos modos. Saludos
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar