Showing image

Thread Solved

Join Date: Oct 2008
Posts: 89
Reputation: sfrider0 is an unknown quantity at this point 
Solved Threads: 0
sfrider0 sfrider0 is offline Offline
Junior Poster in Training

Showing image

 
0
  #1
Jul 28th, 2009
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.
  1. <?php
  2. $row_count = 0;
  3. $columns = 3;
  4. while ($row = mysql_fetch_assoc($result)) {
  5. if ($row_count == $columns) {
  6. echo "</tr><tr>";
  7. $row_count = 0;
  8. }
  9. echo "<tr><td>";
  10. echo $row['Site'];
  11. echo "</td><td>";
  12. echo $row['Description'];
  13. echo "</td><td>";
  14. echo $row['Rating'];
  15. echo "</td>";
  16. $row_count++;
  17. }
  18. ?>
Any help would be greatly appreciated!
Reply With Quote Quick reply to this message  
Join Date: Apr 2006
Posts: 28
Reputation: anuradhu is an unknown quantity at this point 
Solved Threads: 2
anuradhu anuradhu is offline Offline
Light Poster

Re: Showing image

 
1
  #2
Jul 28th, 2009
Use the <img tag inside the ECHO statement.
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 78
Reputation: jino is an unknown quantity at this point 
Solved Threads: 5
jino's Avatar
jino jino is offline Offline
Junior Poster in Training

Re: Showing image

 
1
  #3
Jul 28th, 2009
Like echo "<img src=\"pathto image[imagename]\" >";
We only have to do a very few things right in our life, so long as we don't do too many things wrong.
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 94
Reputation: sureronald is an unknown quantity at this point 
Solved Threads: 15
sureronald sureronald is offline Offline
Junior Poster in Training

Re: Showing image

 
1
  #4
Jul 28th, 2009
  1.  
  2. <?php
  3.  
  4. $row_count = 0;
  5. $columns = 3;
  6.  
  7. while ($row = mysql_fetch_assoc($result)) {
  8.  
  9. if ($row_count == $columns) {
  10.  
  11. echo "</tr><tr>";
  12.  
  13. $row_count = 0;
  14.  
  15. }
  16.  
  17. echo "<tr><td>";
  18.  
  19. echo $row['Site'];
  20.  
  21. echo "</td><td>";
  22.  
  23. echo $row['Description'];
  24.  
  25. echo "</td><td>";
  26.  
  27. echo "<img src=\"{$row['Rating']}\" alt=\"{$row['Description']}\" />";
  28.  
  29. echo "</td>";
  30.  
  31. $row_count++;
  32.  
  33. }
  34.  
  35. ?>
Not the alt attribute with the description just in case the image fails to load.
Last edited by sureronald; Jul 28th, 2009 at 4:57 am. Reason: code errors
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 89
Reputation: sfrider0 is an unknown quantity at this point 
Solved Threads: 0
sfrider0 sfrider0 is offline Offline
Junior Poster in Training

Re: Showing image

 
0
  #5
Jul 28th, 2009
Thanks guys, works great!
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC