1

I am trying to show images in my table which shows through the PHP code, however it gives me an error and I can't figure out where.

echo '<tr><td align="left" valign="top" class="description"> . "<img src='images/" . $product_data["mainImageThumbnail"] . "' alt='Product image' />
    <p><a href="main.php?prodid=' . $product["product_id"] . '">' . $product["name"] . '</a>
    <br /> $products_data["description"] </p>
    <a href="#">Remove</a>
    </td> ';
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129

2 Answers2

1

The problem was the concatenation of PHP with HTML

echo '<tr><td align="left" valign="top" class="description">
<img src="images/' . $product_data["mainImageThumbnail"] . '" alt="Product image" />
<p><a href="main.php?prodid=' . $product["product_id"] . '">' . $product["name"] . '</a>
<br />'. $products_data["description"] .'</p>
<a href="#">Remove</a>
</td> ';
Lucas Henrique
  • 1,380
  • 1
  • 11
  • 15
1
echo '<tr>
    <td align="left" valign="top" class="description">
        <img src="images/' . $product_data["mainImageThumbnail"] . '" alt="Product image"/>
        <p>
            <a href="main.php?prodid=' . $product["product_id"] . '">' . $product["name"] . '</a>
            <br/>' .
            $products_data["description"] . '
        </p>
    <a href="#">Remove</a>
</td> ';
Pankaj Garg
  • 1,272
  • 15
  • 21