Answer the question
In order to leave comments, you need to log in
How to insert a link to a photo taken from sql into the style attribute with the background property?
In short, the inhabitants of habr, the problem is again, here is the code:
<?php while ($article = mysqli_fetch_assoc($articles))
{
?>
<div class="newsblock" style="background:url(https://ссылка.jpeg) 0 0 / auto 100% no-repeat;
">
<div class="base">
<a class="white_font_big" href="#"><?php echo $article['main'];?></a>
<a href="#" class ="white_font_small"><?php echo $article['article_txt'];?></a>
</div>
</div>
<?php } ?>
Answer the question
In order to leave comments, you need to log in
Get the link to the photo in a variable, for example $img
Next
<div class="newsblock" style="background:url(<?php echo $img; ?>) 0 0 / auto 100% no-repeat;">
<div class="newsblock" style="background:url(<?php echo $article['как у тебя называется фон'];?>) 0 0 / auto 100% no-repeat;">
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question