Output Images using PHP

Reply

Join Date: Jan 2008
Posts: 7
Reputation: usc87bb is an unknown quantity at this point 
Solved Threads: 0
usc87bb usc87bb is offline Offline
Newbie Poster

Output Images using PHP

 
0
  #1
Feb 12th, 2008
Hi, I am trying to output images in a table, and what I have is the filename for the picture in my database. My code works when I used a hard-coded test as the image name as I highlight below. So my question is how do I make it to where I can use a variable for the name in the code? I haven't used PHP very much so I don't know all the semantics. Any and all help is GREATLY appreciated!!!

  1. ?>
  2. <table border="0" cellspacing="2" cellpadding="2">
  3. <tr>
  4. <th><font face="Arial, Helvetica, sans-serif">Photo</font></th>
  5. <th><font face="Arial, Helvetica, sans-serif">Brother Name</font></th>
  6. <th><font face="Arial, Helvetica, sans-serif">Major</font></th>
  7. <th><font face="Arial, Helvetica, sans-serif">Phone Number</font></th>
  8. <th><font face="Arial, Helvetica, sans-serif">E-mail Address</font></th>
  9. <th><font face="Arial, Helvetica, sans-serif">Home Town</font></th>
  10. <th><font face="Arial, Helvetica, sans-serif">Alpha Number</font></th>
  11. </tr>
  12.  
  13. <?
  14. $i=0;
  15. while ($i < $num) {
  16. $last=mysql_result($result,$i,"Last_Name");
  17. $first=mysql_result($result,$i,"First_Name");
  18. $major=mysql_result($result,$i,"Major");
  19. $phone=mysql_result($result,$i,"Phone_Number");
  20. $email=mysql_result($result,$i,"Email_Address");
  21. $town=mysql_result($result,$i,"Home_City");
  22. $state=mysql_result($result,$i,"Home_State");
  23. $alpha=mysql_result($result,$i,"Alpha_Number");
  24. $photo=mysql_result($result,$i,"photo_name");
  25. ?>
  26.  
  27. <tr>
  28. -This works when instead of $photo_name I have a hard coded value such as bros/none.jpg
  29. <td><img src=$photo_name width="30" height="30"></td>
  30. <td><font face="Arial, Helvetica, sans-serif"><? echo "$last, $first"; ?></font></td>
  31. <td><font face="Arial, Helvetica, sans-serif"><? echo "$major"; ?></font></td>
  32. <td><font face="Arial, Helvetica, sans-serif"><? echo "$phone"; ?></font></td>
  33. <td><font face="Arial, Helvetica, sans-serif"><? echo "$email"; ?></font></td>
  34. <td><font face="Arial, Helvetica, sans-serif"><? echo "$town, $state"; ?></font></td>
  35. <td><font face="Arial, Helvetica, sans-serif"><? echo "$alpha"; ?></font></td>
  36. </tr>
  37.  
  38. <?
  39.  
  40. ++$i;
  41. }
  42. echo "</table>";
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 3,760
Reputation: nav33n is a jewel in the rough nav33n is a jewel in the rough nav33n is a jewel in the rough 
Solved Threads: 332
Moderator
Featured Poster
nav33n's Avatar
nav33n nav33n is offline Offline
Senior Poster

Re: Output Images using PHP

 
0
  #2
Feb 12th, 2008
  1. <td><img src="<?php echo $photo_name; ?>" width="30" height="30"></td>
Like that !
Ignorance is definitely not bliss!

*PM asking for help will be ignored*
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
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