0

I have created a database. It just contains information about websites. One column has the path to an image, like a rating system(1-5 stars). I just need to display this information on a web page. Everything shows up fine, but I just need it to display the image instead of the path to it.

<?php
$row_count = 0;
$columns = 3;
while ($row = mysql_fetch_assoc($result)) {
if ($row_count == $columns) {
echo "</tr><tr>";
$row_count = 0;
}
echo "<tr><td>";
echo $row['Site'];
echo "</td><td>";
echo $row['Description'];
echo "</td><td>";
echo $row['Rating'];
echo "</td>";
$row_count++;
}
?>

Any help would be greatly appreciated!

4
Contributors
4
Replies
5
Views
7 Years
Discussion Span
Last Post by sfrider0
Featured Replies
  • Use the <img tag inside the ECHO statement. Read More

  • 1

    Like echo "<img src=\"pathto image[imagename]\" >"; Read More

  • [code=php] <?php $row_count = 0; $columns = 3; while ($row = mysql_fetch_assoc($result)) { if ($row_count == $columns) { echo "</tr><tr>"; $row_count = 0; } echo "<tr><td>"; echo $row['Site']; echo "</td><td>"; echo $row['Description']; echo "</td><td>"; echo "<img src=\"{$row['Rating']}\" alt=\"{$row['Description']}\" />"; echo "</td>"; $row_count++; } ?> [/code] Not the alt attribute with … Read More

1
<?php
  
      $row_count = 0;
        $columns = 3;
  
      while ($row = mysql_fetch_assoc($result)) {
  
      if ($row_count == $columns) {
  
      echo "</tr><tr>";
  
      $row_count = 0;
  
      }
  
      echo "<tr><td>";
  
      echo $row['Site'];
  
      echo "</td><td>";
  
      echo $row['Description'];
  
      echo "</td><td>";
  
      echo "<img src=\"{$row['Rating']}\" alt=\"{$row['Description']}\" />";
  
      echo "</td>";
  
      $row_count++;
  
      }
  
      ?>

Not the alt attribute with the description just in case the image fails to load.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.