Click to See Complete Forum and Search --> : xx.php?string BASIC HELP


gabeweb
12-21-2003, 01:30 PM
I am after the help of a genius.

I have a page called index.php and I would like to get variables from the url...
I can handle index.php?id=news, and echo something if that is in the url, by putting "news" into "id".

But im after something a little more advanced...

index.php?news

skipping the "id=news" bit...

would just display news

e.g. the code i thought would work, and what i have at the moment is :

<?php
if($news) {
echo "news stuff tester message";
} ?>

but that does not work (just a blank page).

anyone able to help?

... maybe an environmental variable?

kind regards,

gabe

fredmv
12-21-2003, 04:11 PM
Welcome to the forums.switch($_SERVER['QUERY_STRING'])
{
case 'news':
include 'news.php';
break;

case 'foo':
include 'foo.php';
break;

case 'bar':
include 'bar.php';
break;

default:

break;
}

gabeweb
12-21-2003, 06:32 PM
:p never knew. thank you vverryy much. saved many hours of slavery.
kind regards,
gabe

fredmv
12-21-2003, 08:00 PM
You're quite welcome. :D

gabeweb
12-22-2003, 06:48 PM
is it possible to link this to a mysql query where the case is linked to a query system...

switch($_SERVER['QUERY_STRING'])
{
case '$_SERVER['QUERY_STRING']':
include '';
break;

}

i've been trying this for about 8 hours with different combinations of query code, but i cant get the switch to interface with the query. damn. is it impossible?

for instance im trying to get it so something a record in table "func" would have a "f" (column) value of "cancerresearch", and another record's "f" value would be "help_the_aged".

so index.php?help_the_aged would point to a link in the database or something.

hmmm, should i just do a mysql result for ($_SERVER['QUERY_STRING']), with an error handler?