Page 1 of 1
another problem with variables
Posted: Mon Oct 10, 2005 10:12 am
by sebs
I have 10 tables/page in which I show the results from a search.I need to send the name from the table that is clicked on further with session_start.in $cname I have the value I want to send from every table. The problem is that When I want to send the $cname it always sends the 10th table name(the last on the page).How can I make it send the one is clicked on.I tryed in onclick and a href and is not working
Posted: Mon Oct 10, 2005 10:22 am
by Chris Corbyn
I read your post 3 times over and still don't understand
Showing us the code usually helps to visualise

Posted: Mon Oct 10, 2005 10:26 am
by sebs
Code: Select all
while($data=mysql_fetch_array($result)){
$cname=$data[1];
$cmacro=$data[3];
$ccomune=$data[4];
#.....
?>
<a href="<?php $_SESSION['Name']=$cname;echo"A.DI.GE.htm";?>"
I enter in the while 10 times a page and on $SESSION['Name'] only the last $cname(the 10th) is transmited.If I click on the second I need to send the second $cname
Posted: Mon Oct 10, 2005 10:41 am
by pilau
Ofcourse it'll have only the tenth name, that's because you're putting a value in the same vairable ($cname) everytime you go through the while loop, which is ten times. And thus only the last value remains in $cname.
Posted: Mon Oct 10, 2005 11:25 am
by John Cartwright
$_SESSION['people'][]=$cname;
store the information into an
array
Posted: Mon Oct 10, 2005 11:39 am
by Charles256
or variable variables:-D
Posted: Tue Oct 11, 2005 5:19 am
by sebs
But storing information in an array doesn't solve my problem.How do I know which element from array to transmit?I tryed this but it doesn't work.Could you tell me how can I know which element from array to transmit?
<a href="<?php $_SESSION['people']=$cnm;echo "next.php"?>...>
After everything is outputed if I write like that doesn't transmit the wright one,only the last one.pls help.
Thank you!