/    Sign up×
Community /Pin to ProfileBookmark

xx.php?string BASIC HELP

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

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@fredmvDec 21.2003 — Welcome to the forums.switch($_SERVER['QUERY_STRING'])
{
case 'news':
include 'news.php';
break;

<i> </i>case 'foo':
<i> </i> include 'foo.php';
<i> </i>break;

<i> </i>case 'bar':
<i> </i> include 'bar.php';
<i> </i>break;

<i> </i>default:

<i> </i>break;
}
Copy linkTweet thisAlerts:
@gabewebauthorDec 22.2003 — :p never knew. thank you vverryy much. saved many hours of slavery.

kind regards,

gabe
Copy linkTweet thisAlerts:
@fredmvDec 22.2003 — You're quite welcome. ?
Copy linkTweet thisAlerts:
@gabewebauthorDec 23.2003 — 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?
×

Success!

Help @gabeweb spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.6,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...