在我的MySQL数据库中,我有一个格式为TEXT的字段。
在其中一些列中,它将包含
src =“ / images / imgname.jpg”
当我从数据库中提取数据时,如何找到该文本并在“ / images”前面添加其他文本?
src =“ http://domain.com /images/imgname.jpg”
我不想使它在数据库中永久存在,因为不同的文件有不同的需求。有些不需要绝对路径,而有些则需要。我只想从某些文件中即时添加它们。
谢谢!
里克
最佳答案
您可以使用mysql_fetch_array()将其放入while循环中。
$query = "SELECT query to select the wanted details from the database table.";
$result = mysqli_query($link, $query);
while ($row = $mysqli_fetch_array($result)) {
echo "<img src='/domain.com/images/".$row['image_location']."'>";
}
关于php - 在字符串中查找文本并向其中添加其他文本,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/22924750/