php - 基于 URL ID 加载图像

标签 php html mysql database image

我正在尝试根据 URL 中的 ID 加载图像:

例如:www.exampleurl.com/API/upload/1.jpg 包含一张图片。

当我访问 www.exampleurl.com/photo/index.php?id=1 时,我试图将该图像加载到单独的 PHP 文件中

到目前为止,我的代码似乎不起作用:

<!DOCTYPE html> 
<html>
<head>
</head>
<body>
<?php
    intval($_GET['id']);
?>
    <h1> <center> This is the image: </center> </h1>
    <img src="http://exampleurl.com/API/upload/<?php echo $id;?>.jpg" alt="some_text">
</body>
</html>

如有任何帮助,我们将不胜感激。

最佳答案

    <!DOCTYPE html> 
    <html>
    <head>
    </head>
    <body>
    <?php
        $id = intval($_GET['id']);
    ?>
        <h1> <center> This is the image: </center> </h1>
        <img src="http://exampleurl.com/API/upload/<?php echo $id;?>.jpg" alt="some_text">
    </body>
    </html>

你必须指定 $id

关于php - 基于 URL ID 加载图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17796499/

相关文章:

php - 选择和删除行mysqli查询

javascript - Google map V3 身份验证和重复问题

php - Laravel 从表单输入中将 "null"插入数据库。

mysql - SQL仅选择列上具有最大值的行

javascript - Highcharts 条形图工具提示 HTML 定位

Mysql查询两张表

javascript - 银纹 + 无限 Ajax 卷轴 : None Left keeps being added to page

php - 如何在MySQL中查找不同组中的重复对

php - 什么是 "Array to string error"?

javascript - 从单个下拉框中选择多个选项和值