943,568 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Marked Solved
  • Views: 534
  • PHP RSS
Jul 28th, 2009
0

Showing image

Expand Post »
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 Syntax (Toggle Plain Text)
  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!
Similar Threads
Reputation Points: 16
Solved Threads: 0
Junior Poster
sfrider0 is offline Offline
149 posts
since Oct 2008
Jul 28th, 2009
1

Re: Showing image

Use the <img tag inside the ECHO statement.
Reputation Points: 12
Solved Threads: 2
Light Poster
anuradhu is offline Offline
28 posts
since Apr 2006
Jul 28th, 2009
1

Re: Showing image

Like echo "<img src=\"pathto image[imagename]\" >";
Reputation Points: 10
Solved Threads: 10
Junior Poster
jino is offline Offline
114 posts
since Feb 2008
Jul 28th, 2009
1

Re: Showing image

php Syntax (Toggle Plain Text)
  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
Reputation Points: 11
Solved Threads: 18
Junior Poster
sureronald is offline Offline
139 posts
since May 2008
Jul 28th, 2009
0

Re: Showing image

Thanks guys, works great!
Reputation Points: 16
Solved Threads: 0
Junior Poster
sfrider0 is offline Offline
149 posts
since Oct 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: value in third text box
Next Thread in PHP Forum Timeline: Session gabbage cleaner





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC