can i change info on my page depending on the php?id=(number

can i have it so it displays different information when i change the id?

my page links from index.php to index.php?id=2 can i have that page displaying different information

Short Answer: YES

Long Answer:
Have your query look at the $_GET[‘id’] Variable and run a MySQL Query based on the ID and present the data.

I like to “Initialize” variables as such:

$id = !empty($_GET['id']) ? $_GET['id'] : 1;

That above syntax is the Ternary function that is equivalent to :


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

Have a look at HERE for more info on the Ternary Operator

Sponsor our Newsletter | Privacy Policy | Terms of Service