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> ';
3
  • 1
    <img src='images/" you have a single quote just after src= it should be a ". Didn't continue looking it is always better to always keep html out of php. use only php where you want like <?php echo $product_data["mainImageThumbnail"];?> inside the html Commented Apr 20, 2014 at 16:57
  • 1
    Please check your single and double quotes.They are all aligned wrong Commented Apr 20, 2014 at 16:58
  • If you get an error, give the error message as well (and also search for that error message, at least in the PHP Error Reference we have on site) Commented Apr 20, 2014 at 16:59

2 Answers 2

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> ';
Sign up to request clarification or add additional context in comments.

Comments

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.