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!

Use the <img tag inside the ECHO statement.

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

<?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.

Thanks guys, works great!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.