简体   繁体   中英

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. Now I am trying to figure out a way to combine the PHP & MySQL link to the image into the HTML image code. 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?

<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. But I have tried putting php brackets between the html and everything. 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. and of course the extension of your file should generally be PHP for this to work:

<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'] ?

first of all, your page name must be ending with .php instead of .html,

then try

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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