php从网址获取ID并在网页上显示ID

I am trying to retrieve the ID from the url with php.

The code in this page, has all the video's. With the thumbnail form youtube and when you click on the thumbnail. It redirect to another page with the id in the url.

This is the url when I click on a video: http://pwebsite.project.local/?page=overzichtid?id=4?tag=dorp

This code below is on the page where you can click an video:

<div class="scrollbar">
    <a id="videoList" name="video" href="?page=overzichtid?id='.$videoid.'">
        <img src="' .htmlentities($thumbnail) . '" width="235"/>
        <p id="titelText"><b>' . htmlentities($title) . '</b></p>
    </a>
</div>

Here I am trying with the $_GETmethod to retreive the id. Only when I echo the id it is not shown on the webpage.

This code is in the page overzichtid:

<?php
  $id = $_GET['id'];
  echo $id;
?>

Is this done right or should it be something else to show it on the webpage?

You have two ?in the url. You should use & if you are passing more than 1 variable through querystring.

<div class="scrollbar">
    <a id="videoList" name="video" href="?page=overzichtid&id='.$videoid.'">
        <img src="' .htmlentities($thumbnail) . '" width="235"/>
        <p id="titelText"><b>' . htmlentities($title) . '</b></p>
    </a>
</div>

</div>

When you are in HTML mode, and want to this a PHP variable, this is the syntax:

I think this corrects your DIV situation:

<div class="scrollbar">
    <a id="videoList" name="video" href="?page=overzichtid?id=<?php echo $videoid ?>">
        <img src="<?php echo htmlentities($thumbnail) ?>" width="235"/>
        <p id="titelText"><b><?php echo htmlentities($title) ?></b></p>
    </a>
</div>

$_GET['variable_name'] is used to extract from query string. use & for second variable in query string

It's almost right. After the first query parameter, the following ones must be separated by an '&' not a '?' again:

<div class="scrollbar">
    <a id="videoList" name="video" href="?page=overzichtid&id='.$videoid.'">
        <img src="' .htmlentities($thumbnail) . '" width="235"/>
    </a>
    <p id="titelText"><b>' . htmlentities($title) . '</b></p>
</a>

And it's a good practice not trust in form/query parameters. You should always check their existence:

<?php
$id = !empty($_GET['id']) ? $_GET['id'] : null;
if (empty($id)) {
    //e.g.:redirect to previous page
}
echo $id; //here is safe to use id
?>

You have 2 ? marks in your url, but another true problem you have is because the PHP variable $videoid is never inserted into your url...

This code:

<div class="scrollbar">
    <a id="videoList" name="video" href="?page=overzichtid?id='.$videoid.'">
        <img src="' .htmlentities($thumbnail) . '" width="235"/>
        <p id="titelText"><b>' . htmlentities($title) . '</b></p>
    </a>
</div>

Has the problem where you are attempting to display the PHP id variable into the HTML

<id="videoList" name="video" href="?page=overzichtid?id='.$videoid.'">

You have not instructed php to evaluate a section of PHP in your html file. The correction for this would be:

<a id="videoList" name="video" href="?page=overzichtid&id=<?=$videoid;?>">

<div class="scrollbar">
    <a id="videoList" name="video" href="?page=overzichtid&id=<?=$videoid;?>">
        <img src="' .htmlentities($thumbnail) . '" width="235"/>
        <p id="titelText"><b>' . htmlentities($title) . '</b></p>
    </a>
</div>