You are here: Re: Hyperlink and passing of variables. « PHP Programming Language « IT news, forums, messages
Re: Hyperlink and passing of variables.

Posted by Shelly on 07/24/05 16:00

<opt_inf_env@yahoo.com> wrote in message
news:1122208838.784277.10610@g43g2000cwa.googlegroups.com...
>I am not sure, that I understood what I need to do.
>
>> Create a variable which is an array. Put in the values you want for
>> each variable as:
>> theArray['first_var'] = first value;
> OK. Let say in the file "first.php" I write:
> theArray[first] = "aaaa";
> theArray[second] = "bbb";
> Is it what I need to do?
>
>> Then create a single session variable which is $_SESSION['theValues'] =
>> $theArray
> What does it mean "to create session variable"? I think I need to
> open session by "session_start();" and then I register a session
> variable by "session_register( "_SESSION" );", where _SESSION is
> the variable name. Do I correctly understand? By the way, what for I
> need to put "magical" symbol "_" in the variable name?

No. Here it is (assuming your are at PHP 4 or greater).

To create the session variable you do:

$_SESSION['the_variable_name_you_choose'] =
the_value_or_variable_to_be_assigned_to_it;

The variable name is anything you want. All you need be consistent about is
using the same index in both the setting and the using pages.

Example 1:
in the setting page
$_SESSION['my_address'] = 'this_is_my_address';
in the using page:
$myAge = $_SESSION['my_address'];

The variable $myAge will contain the value 'this_is_my_address'.

Example 2:
in the setting page:
$theArray = array();
$theArray['my_address'] = 'this_is_my_address';
$theArray['my_name'] = 'this_is_my_name';
$_SESSION['my_values'] = $theArray;

in the using page:
$anArray = $_SESSION['my_values'];
and you have
$anArray['my_address'] and $anArray['my_name'] having the correct values.

What I was asking was that in example 2 if you did
<a href=URL_of_using_page?thevalues=<?php echo $theArray ?> >
and in the using page use
$anArray = $_GET['thevalues'];
would that work? I think so, but am not sure. I am sure that example 2
works.

Shelly

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация