0

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..

Till Helge
  • 9,253
  • 2
  • 40
  • 56
vvk
  • 113
  • 1
  • 15

3 Answers3

2

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

prodigitalson
  • 60,050
  • 10
  • 100
  • 114
1

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'
)
Ben D
  • 14,321
  • 3
  • 45
  • 59
0

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

Mihai Matei
  • 24,166
  • 5
  • 32
  • 50