HI guys,
just wondering how to get a customised page, depending on an id. Eg mysite.org/view?id=1, mysite.org/view?id=2 etc. How does that work? Is it possible to provide the whole url including the id so I can put a direct link to the page I want someone to view?

Cheers,

Recommended Answers

All 3 Replies

Within php, you can retrieve the URL variables (in your case, the id) with the $_GET variable. Please see http://us2.php.net/manual/en/reserved.variables.get.php for reference.

To get the ID that you specify in the URL, you'd use

$id = $_GET['id'];

Is this what your looking for?

nice one. Yes it is.

One final question: Is there a way to set a default page if there is no parameter after view.php?

In this instance, I want it to be id to be 1.

if (isset($_GET['id'])) {
$id = $_GET['id'];
} else {
$id = 1;
}

~G

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.