problems with passing session variable to another page.

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
aarhus
Forum Newbie
Posts: 2
Joined: Thu Mar 22, 2007 3:12 am

problems with passing session variable to another page.

Post by aarhus »

Hello there,

I have got one problem here. This is the main php file:

Code: Select all

<?

	session_start();

   include "../inc/dbconnect.php";

?>

<html>
<head>
<title>Search</title>
<meta http-equiv="Content-Type" content="text/html; windors-1271">
</head>

<body bgcolor="#FFFFFF" text="#000000">



<?

	switch( $_GET["action"] )
	{
		case "search": // show search results
		{
			include_once("../inc/search_results.php");
                	break;
		}
		
		case "details": // show search results
		{
			include_once("../inc/products.php");
                	break;

		}
		
		default: // default search form
		{
			include_once("../inc/search.php");
                	break;
		}

	}

?>

</body>
</html>
So, when I get a list of search results on search_results.php I want to click on any search_result and I want to pass the row['filmid'] to the page products.php so that products.php will display all info about any product. The problem is that when I get the row id with $_session['filmid'] from search_results.php to products.php, I get the id of the only the last search_result but not the one I click. I dont get the reason for that.

This is my search_results.php page:

Code: Select all

<?

.......................

//echo ("$query");

include_once("dbconnect.php");
$result = mysql_query($query);

$num_results = @mysql_num_rows($result);

echo '<p>Number of DVDs found: '.$num_results.'</p>';

for ($i=0; $i <$num_results; $i++)
  {
     $row = mysql_fetch_assoc($result);
    echo '<p><strong>' .($i+1). 'Title: <a href="search_form.php?action=details"></a></strong><br />';
    echo 'Items in Stock: ' . $row['itemsinstock'] . '<br /> ';
    echo 'Extrainfo: ' . $row['extrainfo'] . '<br />';
    echo 'Price: ' . $row['price'] . '</p>';



$_SESSION['filmid']=$row['filmid'];

echo ($_SESSION['filmid']);

 
  }
  
  
?>
I hope you can help me with this problem.

Thanks in advance

d11wtq | Please wrap

Code: Select all

 [/ php] tags around your code when posting <?php ?> code in the forum[/color][/b]
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

Why is this in DevNetwork Forums Forum Index -> PHPDN Suggestions ?
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

:arrow: Moved to PHP Code
Post Reply