Reputation: 35
I have code like this ;
$Photo = filtering($row['FileIcon128']);
<div class="image" style="background:url(/images/imgs/<?php echo $Photo ?>)"></div>
I tried everything
filtering($row['FileIcon128']); , echo ''.$Photo.'';
instead of
$Photo
But i cant get picture. Any idea?
By the way, i have to use
<div class="image"
Upvotes: 2
Views: 223
Reputation: 810
Give this a shot:
<?php
$Photo = filtering($row['FileIcon128']);
$string = "/images/imgs/" . $Photo;
?>
<div class="image" style="background-image:url('<?php echo $string; ?>')"></div>
I saw 3 possible bugs in your code, which were:
1) <?php echo $Photo ?>
without a semicolon after $Photo
. I don't know if that's a syntax error or not in inline php, however I added the semicolon to make sure and concatenated the static string with the dynamic variable to make for a less messy inline PHP like this: <?php echo $string; ?>
.
2) background:url()
is not the right way to do this. You want to be as explicit as you can, so background-image:url()
.
3) background-image:url()
without '' (apostrophes) surrounding the parameter passed. background-image:url('')
fixed that. I just echoed the code in between the two apostrophes.
Upvotes: 2