How to pass variable(which stores string) from one page to next while using dynamic link?

244 Views Asked by At

On my first page I have created dynamic link this way:

do
{
   $FilterModule = $row_mysql['Module']; /* Say it's value is 'xyz' for particular case */
   echo "<a href='filterquery.php?filter=$FilterModule'>$FilterModule</a>";
} while($row = mysql_fetch_array($QueryResult));

Now when i click on above link from the first page, it takes me to a second page with url: filterquery.php?filter=xyz. On this page I am using $FilterModule = $_GET['FilterModule']; to get the value(='xyz'). But I get an error:

'Undefined index: FilterModule'.

Not sure what mistake i am making? Please help..

3

There are 3 best solutions below

0
On

You should be using $_GET['filter']; because thats what you called the parameter in the URL.

0
On

You need to use $_GET['filter'] rather than $_GET['FilterModule'] because that's the name of the parameter you're assigning a value to in the URL.

When you access the GET array, it uses the variables passed in the URL, so

filterquery.php?filter=xyz&filter2=abc

would produce the following key-value pairs in the _GET array:

$_GET = array(
   [filter]  = 'xyz',
   [filter2] = 'abc'
)
0
On

You can get that value with $_GET['filter'] which is the parameter given in filterquery.php?filter=xyz