使用 php 在 html table 中回显图像
echo an image inside html table using php
我尝试使用 PHP 生成一个只有 2 个单元格的 html table。第一个 table 单元格是一个图像,第二个单元格有另一个 table。我可以将我想要的数据放在第二个单元格中(table 格式)。但无法在第一个 table 单元格中显示图像。
搜索论坛显示了一些与issue相关的已解决的echo,但并不能解决我的问题。
这是我使用的代码,
if(array_filter($values2))
{
echo "<!DOCTYPE html>";
echo "<html>";
echo "<head>";
echo "<table>";
echo "<tr>";
echo "<td>";
echo "<img src = treedir . '/' . $tffam;?>"; //my problem here
echo "</td>";
echo "<td>";
//a table generating code and it works fine
echo "</td>";
echo "</tr>";
echo "</body>";
echo "</html>";
}
问题出在 " 和 '。试试这个:
echo "<img src='/treedir/" . $tffam . "'/>";
你可以试试这个:
echo "<img src='treedir/$tffam' alt='some text' >";
我尝试使用 PHP 生成一个只有 2 个单元格的 html table。第一个 table 单元格是一个图像,第二个单元格有另一个 table。我可以将我想要的数据放在第二个单元格中(table 格式)。但无法在第一个 table 单元格中显示图像。
搜索论坛显示了一些与issue相关的已解决的echo,但并不能解决我的问题。
这是我使用的代码,
if(array_filter($values2))
{
echo "<!DOCTYPE html>";
echo "<html>";
echo "<head>";
echo "<table>";
echo "<tr>";
echo "<td>";
echo "<img src = treedir . '/' . $tffam;?>"; //my problem here
echo "</td>";
echo "<td>";
//a table generating code and it works fine
echo "</td>";
echo "</tr>";
echo "</body>";
echo "</html>";
}
问题出在 " 和 '。试试这个:
echo "<img src='/treedir/" . $tffam . "'/>";
你可以试试这个:
echo "<img src='treedir/$tffam' alt='some text' >";