another problem with variables

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
sebs
Forum Commoner
Posts: 97
Joined: Tue Sep 20, 2005 10:13 am

another problem with variables

Post 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
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

I read your post 3 times over and still don't understand :?

Showing us the code usually helps to visualise ;)
sebs
Forum Commoner
Posts: 97
Joined: Tue Sep 20, 2005 10:13 am

Post 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
pilau
Forum Regular
Posts: 594
Joined: Sat Jul 09, 2005 10:22 am
Location: Israel

Post 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.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

$_SESSION['people'][]=$cname;

store the information into an array
Charles256
DevNet Resident
Posts: 1375
Joined: Fri Sep 16, 2005 9:06 pm

Post by Charles256 »

or variable variables:-D
sebs
Forum Commoner
Posts: 97
Joined: Tue Sep 20, 2005 10:13 am

Post 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!
Post Reply