Adam Yankovic
Adam Yankovic

Reputation: 29

PHP code parse error, maybe just wrong formating

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> ';

Upvotes: 1

Views: 41

Answers (2)

Pankaj Garg
Pankaj Garg

Reputation: 1322

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> ';

Upvotes: 1

Lucas Henrique
Lucas Henrique

Reputation: 1364

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> ';

Upvotes: 1

Related Questions