Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I have this code on php:

$query = "select * from product";
$result = mysql_query($query);
 <?php

  while($row = mysql_fetch_array($result))
  {

    echo "<tr>";
    echo "<td>" .$row['ProductName']. "</td>";
    echo "<td>" .$row['Price']. "</td>";
    echo "<td>" .$row['Stock']. "</td>";
    echo "<td><img src=photos/'". $row['ProductImage']. "'/></td>";
    echo "</tr>";
   }
  ?>

But the images from the sql database won't be shown. It only appear like the image I attached. Products Table

share|improve this question

closed as too localized by andrewsi, Jean-Bernard Pellerin, Emil Adz, Muhammad Reda, Trinimon May 18 '13 at 6:47

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

1 Answer 1

up vote 2 down vote accepted

First for broken images, check the source code / the image URL in the page to check you're getting the right HTML. In your case,

echo "<td><img src=photos/'". $row['ProductImage']. "'/></td>";

This is going to show up as <img src=photos/'productimage.png'/> for example. The ' needs to encapsulate the photos/ part too to be valid.

Change

echo "<td><img src=photos/'". $row['ProductImage']. "'/></td>";

to

echo "<td><img src='photos/". $row['ProductImage']. "'/></td>";

and assuming that the URL is correct then, it will work.

share|improve this answer
    
It works! Thanks you so much.. –  Adyana Permatasari May 17 '13 at 2:24

Not the answer you're looking for? Browse other questions tagged or ask your own question.