简体   繁体   English

将HTML链接转换为PHP链接?

[英]Converting HTML links to PHP links?

again this user profile website has stumped me... I figured out how to show images that the logged in user has uploaded, to use as a display picture. 这个用户个人资料网站再次让我感到难过...我想出了如何显示已登录用户上传的图像,以用作显示图片。 Problem is I couldn't figure out a simple way to resize the image once it shown. 问题是一旦显示图像,我就无法想出一种简单的方法来调整图像大小。 So I used a image holder type script from my HTML page. 因此,我使用了HTML页面中的图片持有人类型脚本。 Now I am trying to figure out a way to combine the PHP & MySQL link to the image into the HTML image code. 现在,我试图找出一种将PHP和MySQL链接到图像的代码合并为HTML图像代码的方法。 Basically my question is, is there a way to convert the script below in to a PHP script or get it working in HTML form? 基本上我的问题是,是否有办法将下面的脚本转换为PHP脚本或使其以HTML格式工作?

<a class="img-thumbnail lightbox pull-left" href="" data-plugin-options='{"type":"image"}'>
                            <img class="img-responsive" width="215" src="link-to-the-image">
                            <span class="zoom">
                            <i class="icon icon-16 icon-white-shadowed icon-search"></i>
                            </span>
                        </a> 

I am trying to get this link to the image to work within the above script because this is the image that I would like to show: 我试图获得指向图像的链接以在上述脚本中工作,因为这是我想要显示的图像:

echo "http://basecentre.co.uk/user_bc_74hw438eryer90reh0e9rh83232_members/upload/".$_SESSION['photo']."";

Tried the following but no luck, no image shown... 尝试了以下方法,但没有运气,没有显示图像...

<a class="img-thumbnail lightbox pull-left" href="" data-plugin-options='{"type":"image"}'>
                            <img class="img-responsive" width="215" src="http://basecentre.co.uk/user_bc_74hw438eryer90reh0e9rh83232_members/upload/".$_SESSION['photo']."">
                            <span class="zoom">
                            <i class="icon icon-16 icon-white-shadowed icon-search"></i>
                            </span>
                        </a>

Probably because it's in HTML form... Argh. 可能是因为它是HTML格式...啊。 But I have tried putting php brackets between the html and everything. 但是我尝试将php放在html和所有内容之间。 Confussed?? 感到困惑?

First echo your session var, photo to see if it contains anything, then check if your session is started if it does not then Try setting your session variable to a separate variable then echo the whole thing like: 首先回显您的会话变量,图片以查看是否包含任何内容,然后检查会话是否启动,然后尝试将会话变量设置为单独的变量,然后回显整个过程,例如:

$img = $_SESSION['photo'];
echo "http://basecentre.co.uk/user_bc_74hw438eryer90reh0e9rh83232_members/upload/$img";

you need to open and close php tags, if you need to include php code to your html. 如果您需要将php代码包含到html中,则需要打开和关闭php标签。 and of course the extension of your file should generally be PHP for this to work: 当然,文件的扩展名通常应该是PHP才能起作用:

<img class="img-responsive" width="215" src="http://basecentre.co.uk/user_bc_74hw438eryer90reh0e9rh83232_members/upload/<?php echo $_SESSION['photo']; ?>">

i don't fully understand you question but i think you want to echo $_SESSION['photo'] ? 我不完全理解您的问题,但我想您想回应$_SESSION['photo']吗?

first of all, your page name must be ending with .php instead of .html, 首先,您的页面名称必须以.php而不是.html结尾,

then try 然后尝试

    <?php session_start();
        echo $_SESSION['photo'];
    ?>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM