简体   繁体   中英

Echo image in wordpress php with SQL variable

For the life of me I can't find why this line doesn't output an image in a table.

echo "<td>" . "<img src=/images/helmets/" . $row["Flag1"] . ".png>" . "</td>"

I'm sure it's a " issue.

I know that the sql output is correct because echo $row["Flag1"] give the correct result but I can't get it to display a png with the same name.

I am using "Allow PHP" in wordpress

Any help would be hugely appreciated.

src needs to have its value between '' or "". You can try this

echo "<td>" . "<img src='/images/helmets/" . $row["Flag1"] . ".png'>" . "</td>"

假设$row['Flag1']具有有效值,请尝试以下操作

echo "<td><img src=\"/images/helmets/{$row['Flag1']}.png\"></td>";

谢谢大家,当我意识到文件名上的大写字母有所不同并进行了更改时,所有这些都包括我的工作。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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