Discussion
I'm looking to write some code that will display content (from an XML source) depending on whats in the URL/Address Bar. An example of this could be www.asite.com/fetch.php?=cars
Does this make any sense? Basically a searchbox on another page would send the user to a page with the url above, the page shown would pull XML source according to the bit following the '?'
Can anyone help, i've set up a phpBB board, but this is way beyond me.
Does this make any sense? Basically a searchbox on another page would send the user to a page with the url above, the page shown would pull XML source according to the bit following the '?'
Can anyone help, i've set up a phpBB board, but this is way beyond me.

all you need is the following code:
require($_GET['parameterName']."htm"
;
where parameter name is "pageName?parameterName=something" and .htm is the extension you want. Wrap that in PHP tags and jobs a goodun.
edit: You may want some rudimentary validation on there mind, this is what I use on my page:
<?PHP
$page = "";
if(isSet($_GET['menu']))
if($_GET['menu'] == "pic"
$page = "pic";
if($_GET['menu'] == "marlinLinks"
$page = "links";
else if(isSet($_GET['menu']) && !isSet($_GET['type']))
$page = $_GET['menu'];
else if(isSet($_GET['menu']) && isSet($_GET['type']))
$page = $_GET['menu']."/".$_GET['type'];
else
$page = "index";
$page = "pages/".$page.".php";
if(file_exists($page))
require_once($page);
else
echo ("File Not Found: ".$page. " ". $_GET['menu']);
?>
>> Edited by docevi1 on Saturday 11th March 18:07
require($_GET['parameterName']."htm"
; where parameter name is "pageName?parameterName=something" and .htm is the extension you want. Wrap that in PHP tags and jobs a goodun.
edit: You may want some rudimentary validation on there mind, this is what I use on my page:
<?PHP
$page = "";
if(isSet($_GET['menu']))
if($_GET['menu'] == "pic"
$page = "pic";
if($_GET['menu'] == "marlinLinks"
$page = "links";
else if(isSet($_GET['menu']) && !isSet($_GET['type']))
$page = $_GET['menu'];
else if(isSet($_GET['menu']) && isSet($_GET['type']))
$page = $_GET['menu']."/".$_GET['type'];
else
$page = "index";
$page = "pages/".$page.".php";
if(file_exists($page))
require_once($page);
else
echo ("File Not Found: ".$page. " ". $_GET['menu']);
?>
>> Edited by docevi1 on Saturday 11th March 18:07
And no surprise, I couldn't get it to work (my coding skills no doubt)!
Got this error:
Parse error: syntax error, unexpected T_VARIABLE in /hsphere/local/home/test.php on line 6
Below is also a better example of what i'm after:
google.co.uk/search?hl=en&q=test&meta=
"test" being the term for which I wish to display data for on the page.
Can anyone help such a useless programmer as myself?
Got this error:
Parse error: syntax error, unexpected T_VARIABLE in /hsphere/local/home/test.php on line 6
Below is also a better example of what i'm after:
google.co.uk/search?hl=en&q=test&meta=
"test" being the term for which I wish to display data for on the page.
Can anyone help such a useless programmer as myself?
MyNameIsMud said:
And no surprise, I couldn't get it to work (my coding skills no doubt)!
Got this error:
Parse error: syntax error, unexpected T_VARIABLE in /hsphere/local/home/test.php on line 6
Below is also a better example of what i'm after:
google.co.uk/search?hl=en&q=test&meta=
"test" being the term for which I wish to display data for on the page.
Can anyone help such a useless programmer as myself?![]()
<?php
if (isset($_GET["q"]))
{
$contentToDisplay = $_GET["q"];
}
else
{
echo "Parameter not set";
}
?>
EDIT: Obviousl though this wouldn't work if the page you were looking at was google.co.uk!
>> Edited by zoidberg on Sunday 12th March 16:59
Gassing Station | Computers, Gadgets & Stuff | Top of Page | What's New | My Stuff



