如何将此 php 放入图像背景 url 中?
How can I put this php into a image background url?
我将非常感谢在这方面的帮助:
我有一个 bootstrap 旋转木马,我想包含来自数据库的图片。我希望它显示为这样的背景图片:
<div class="carousel-item" style="background-image: url('link to image')">
这是我要为上述 'link to image':
添加的 PHP-片段
<?php
$img_url = "images/programpics/"; {
echo '<img src="' . $img_url . $row_firstrow[ 'show_tix_phone' ] . '"id="pic1" alt="Something here" />';
}
?>
希望得到帮助:
<div class="carousel-item" style="background-image: url(<?php echo $img_url . $row_firstrow[ 'show_tix_phone' ] ?>)">
'Link to image' 是样式的一部分,不允许 html 标签,如 'img' 和尖括号。示例语法:
background-image: url('images/bg.jpg')
考虑到这一点,您的代码必须是这样的:
<div class="carousel-item" style="background-image: url('<?php
$img_url = "images/programpics/";
{
echo $img_url . $row_firstrow[ 'show_tix_phone' ];
}
?>')" id="pic1" alt="Something here" />';
我将非常感谢在这方面的帮助: 我有一个 bootstrap 旋转木马,我想包含来自数据库的图片。我希望它显示为这样的背景图片:
<div class="carousel-item" style="background-image: url('link to image')">
这是我要为上述 'link to image':
添加的 PHP-片段<?php
$img_url = "images/programpics/"; {
echo '<img src="' . $img_url . $row_firstrow[ 'show_tix_phone' ] . '"id="pic1" alt="Something here" />';
}
?>
希望得到帮助:
<div class="carousel-item" style="background-image: url(<?php echo $img_url . $row_firstrow[ 'show_tix_phone' ] ?>)">
'Link to image' 是样式的一部分,不允许 html 标签,如 'img' 和尖括号。示例语法:
background-image: url('images/bg.jpg')
考虑到这一点,您的代码必须是这样的:
<div class="carousel-item" style="background-image: url('<?php
$img_url = "images/programpics/";
{
echo $img_url . $row_firstrow[ 'show_tix_phone' ];
}
?>')" id="pic1" alt="Something here" />';