Page 1 of 1

Session Question

Posted: Sun Jul 11, 2004 8:49 pm
by dardsemail
Hi,

I'm trying to set a session value based on a row value - but when I set it and call the value from within another page, I'm not getting the correct row value.

Here's my code from where I'm setting the session value:

Code: Select all

<?php
while ($row=@mysql_fetch_array($result))
					{ ?>
  					<tr>
   					<td style="border:1px solid rgb(75, 29, 121);"><h1><?php echo $row['eventDate'];?></h1></td>
					<td style="border:1px solid rgb(75, 29, 121);"><?php $_SESSION['eventName']=$row['eventName'];?><a href="eventdetails.php"><h2><?php echo $row['eventName'];?></h2></a></td>
					<td style="border:1px solid rgb(75, 29, 121);"><h1><?php echo $row['eventLocation'];?></h1></td>
  					</tr><?php
					}
?>
Here's my code to call the values based on the session value from the results page:

Code: Select all

<?php
include ("Connections/ccaa.php");
$eventName = $_SESSION['eventName'];
$query = "SELECT * FROM events_tb WHERE eventName = '$eventName'";
$result = mysql_query ($query);
$row = mysql_fetch_array ($result);

?>
I'm getting a result, so I know its not a syntax problem - but the issue is that the session value doesn't seem to change no matter what row I select.

Is there a better way to do what I'm trying to do? Given that I'm a total newbie, I'm sure that there is ;-)

Thanks!

Posted: Sun Jul 11, 2004 8:52 pm
by feyd
$_SESSION['eventName'] looks like it'll always be the last one in the results... you'll need to pass the data via the url it appears.

Posted: Sun Jul 11, 2004 9:23 pm
by dardsemail
Thanks Feyd! I appreciate that. Big bummer though - I was hoping to avoid passing the data via URL. Oh well. Guess I'll have to do it that way after all.

Thanks!