Hello i want to divide my php page with diffrent sections
i know how to do file.php?section=test
but how can i just do file.php?test
i have tryed
if($HTTP_GET_VARS['test'] == "") {
echo "test";
}
but this does not work
Any help?
Thanks Oli
pHx wrote:i have tryed if($HTTP_GET_VARS['test'] == "") { echo "test"; } but this does not work
because the GET variable test is set to nothing. if you are sure that the "section" var will be the first GET var then you could do:
$section = array_values(array_flip($_GET)); echo $section[0];
How would i use that array in an IF statement to check if the correct $GET had been performed?
when you say "correct" i assume you mean one of a limited list of allowed sections? if so then store the allowed list as an array and use [man]in_array[/man] to check.
No i mean as in an IF statement.
So if test.php?contact is called there is an IF statement to some code in the statement.
Like i have done with the HTTP_GET_VARS but i just need it with test.php?contact .
Couldn't you use isset()?
// page.php?test if (isset($_GET['test'])) echo "Test is a var!!!";
Or, use a foreach loop:
foreach ($_GET as $var => $val) if ($var == "test") echo "Var is test!!!";
Works just like i want to 🙂
Thanks very much LoganK
Oli
Congrats on getting it resolved!
Now mark it resolved: "Thread Tools" -> "Mark Thread Resolved"