I have a web in which I want to pass a variable from one page to another but I only get to recognize the database ID, when I change the parameter it does not show me anything. I pass the code that works for me and also the code that gives me problems.
This code works:
<a href="visualizar-informe-alta.php?id=<?php echo htmlentities($result->id);?>"><img src="images/ver-paciente.png" alt="Ver Informe" height="25" width="25" title="Visualizar Informe"></a>
<?php
session_start();
error_reporting(0);
include('includes/config.php');
if(strlen($_SESSION['alogin'])=="")
{
header("Location: index.php");
}
else{
$id=intval($_GET['id']);
?>
<?php
$sql = "SELECT 'id', 'fecha_alta', 'cip_paciente', 'nombre', 'apellidos', 'edad', 'sexo', 'servicio', 'modalidad', 'up_que_consulta', 'cod_grupo_patologia', 'cod_cie9', 'dolor', 'fuerza', 'movilidad', 'dependencia', 'otros_parametros', 'motivo_alta' FROM 'informe_de_alta' WHERE id=:id";
$query = $dbh->prepare($sql);
$query->bindParam(':id',$id,PDO::PARAM_STR);
$query->execute();
$results=$query->fetchAll(PDO::FETCH_OBJ);
foreach($results as $result)
?>
This code is the one that does not work for me:
<a href="visualizar-informe-alta.php?cip_paciente=<?php echo htmlentities($result->cip_paciente);?>"><img src="images/ver-paciente.png" alt="Ver Informe" height="25" width="25" title="Visualizar Informe"></a>
<?php
session_start();
error_reporting(0);
include('includes/config.php');
if(strlen($_SESSION['alogin'])=="")
{
header("Location: index.php");
}
else{
$cip_paciente=intval($_GET['cip_paciente']);
?>
<?php
$sql = "SELECT 'id', 'fecha_alta', 'cip_paciente', 'nombre', 'apellidos', 'edad', 'sexo', 'servicio', 'modalidad', 'up_que_consulta', 'cod_grupo_patologia', 'cod_cie9', 'dolor', 'fuerza', 'movilidad', 'dependencia', 'otros_parametros', 'motivo_alta' FROM 'informe_de_alta' WHERE cip_paciente=:cip_paciente";
$query = $dbh->prepare($sql);
$query->bindParam(':cip_paciente',$cip_paciente,PDO::PARAM_STR);
$query->execute();
$results=$query->fetchAll(PDO::FETCH_OBJ);
foreach($results as $result)
?>
What could it be?