简体   繁体   English

需要最简单的方法来使用 MySQL 中的照片更改标题的背景

[英]Need the simplest way possible to change the background of a header with a photo from MySQL

I need the simplest way possible to use the photo I've inserted into MySQL through a form line of code.我需要最简单的方法来使用我通过一行代码插入到 MySQL 中的照片。 That part works(I think) and the photo is in the MySQL database in a text format ''photo.jpg''.那部分有效(我认为),照片以文本格式“photo.jpg”在 MySQL 数据库中。 But I've been struggling on a way to extract it from the database and make it a background of a header through mysql_fetch_assoc I'm using to display the other data.但是我一直在努力从数据库中提取它并通过我用来显示其他数据的 mysql_fetch_assoc 使其成为标题的背景。 It works well for the other data, but I can't figure it out for the pic... If anyone has a way to do it, for it to be a simple and as short as possible它适用于其他数据,但我无法为图片弄清楚......如果有人有办法做到这一点,它会尽可能简单且尽可能短

<header class="masthead" style="background-image: url('assets/img/post-bg.jpg')">

This is the code for the current header with a fixed image instead of the changeable one which I need这是具有固定图像而不是我需要的可变图像的当前标题的代码

You can do an inline echo:你可以做一个内联回显:

<header class="masthead" style="background-image: url('assets/img/<?php echo $row['image']; ?>')">

Obviously change $row and image to the values that you are using in your script.显然将 $row 和 image 更改为您在脚本中使用的值。

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

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