I've seen that there is a question: PHP Pass variable to next page
but it doesn't work for me.
I would like to parse for instance $variable to another php file, and it has to be in an href atribute.
I have a "while" and when the user clicks in the link I have to store the current value in a variable to parse it to another file.
I've alredy tried with sessions variable, but in my case, I have a query with lots of rows, and I have a variable where I put data. So, for each row, the user sees a link. When he clicks, I have to parse the variable to the other php file.
Just in case, I leave here the code
<div class="container">
<!-- Obtengo datos -->
<?php
$conexion=mysql_connect('localhost','root','root') or die('No hay conexión a la base de datos');
$db=mysql_select_db('carpe',$conexion)or die('no existe la base de datos.');
$id= $_SESSION['id'];
$consulta=mysql_query("select * from(select * from messages m where 1> (select count(*) from messages m1 where m.id<m1.id and m.idm=m1.idm))c
where id_from='".$id."' or id_to='".$id."'");
while($filas=mysql_fetch_array($consulta)){
$idm=$filas['idm'];
$id=$filas['id'];
$id_to=$filas['id_to'];
$id_from=$filas['id_from'];
$status=$filas['status'];
$text=$filas['text'];
$time=$filas['time'];
$consulta2=mysql_query("select * from users where id='".$id_from."'");
while($filas2=mysql_fetch_array($consulta2)){
$Nombre_enviador=$filas2['username'];
}
$consulta3=mysql_query("select * from users where id='".$id_to."'");
while($filas3=mysql_fetch_array($consulta3)){
$Nombre_receptor=$filas3['username'];
}
$username= $_SESSION['username'];
$_SESSION['idm'] = $idm;
echo "mensaje id: ".$idm;
?>
<div class="maincontent">
<h3><a href="#">Asunto: <?php echo $idm?></a></h3>
<span class="postInfo">Enviado por:
<?php
if($Nombre_enviador==$username){
?> <a href="#">Ti</a>
<?php
}else{
?><a href="#"><?php echo $Nombre_enviador ?></a>
<?php } ?>
A
<?php
if($Nombre_receptor==$username){
?> <a href="#">Ti</a>
<?php
}else{
?><a href="#"><?php echo $Nombre_receptor ?></a>
<?php } ?>
- <?php echo $time ?></span>
<p><?php echo $text ?></p>
<a class="more" href="conversacion.php?a=register">Responder</a>
<?php
if(isset($_GET['a']) /*you can validate the link here*/){
$_SESSION['link']=$_GET['a'];
}
?>
<hr>
<?php } ?>
<hr>
</div>
I hope you understand it, thank you a lot!