| | |
Output Images using PHP
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Jan 2008
Posts: 7
Reputation:
Solved Threads: 0
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!!!
PHP Syntax (Toggle Plain Text)
?> <table border="0" cellspacing="2" cellpadding="2"> <tr> <th><font face="Arial, Helvetica, sans-serif">Photo</font></th> <th><font face="Arial, Helvetica, sans-serif">Brother Name</font></th> <th><font face="Arial, Helvetica, sans-serif">Major</font></th> <th><font face="Arial, Helvetica, sans-serif">Phone Number</font></th> <th><font face="Arial, Helvetica, sans-serif">E-mail Address</font></th> <th><font face="Arial, Helvetica, sans-serif">Home Town</font></th> <th><font face="Arial, Helvetica, sans-serif">Alpha Number</font></th> </tr> <? $i=0; while ($i < $num) { $last=mysql_result($result,$i,"Last_Name"); $first=mysql_result($result,$i,"First_Name"); $major=mysql_result($result,$i,"Major"); $phone=mysql_result($result,$i,"Phone_Number"); $email=mysql_result($result,$i,"Email_Address"); $town=mysql_result($result,$i,"Home_City"); $state=mysql_result($result,$i,"Home_State"); $alpha=mysql_result($result,$i,"Alpha_Number"); $photo=mysql_result($result,$i,"photo_name"); ?> <tr> -This works when instead of $photo_name I have a hard coded value such as bros/none.jpg <td><img src=$photo_name width="30" height="30"></td> <td><font face="Arial, Helvetica, sans-serif"><? echo "$last, $first"; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><? echo "$major"; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><? echo "$phone"; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><? echo "$email"; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><? echo "$town, $state"; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><? echo "$alpha"; ?></font></td> </tr> <? ++$i; } echo "</table>";
php Syntax (Toggle Plain Text)
<td><img src="<?php echo $photo_name; ?>" width="30" height="30"></td>
Ignorance is definitely not bliss!
*PM asking for help will be ignored*
*PM asking for help will be ignored*
![]() |
Similar Threads
- About image mirroring using php (PHP)
- Open In New Window Php (PHP)
- php read text scanned from other text editor (PHP)
- it's simple but yet complicated...php and mysql search.. (PHP)
- php url code? (PHP)
- Slideshow Des/Dev - PHP/SQL/XML/FLASH/AS/AJAX, not all needed but it wouldn't hurt. (Web Development Job Offers)
- Problems using a php generator (PHP)
- File upload problem (PHP)
- Php Mysql Image Question (PHP)
Other Threads in the PHP Forum
- Previous Thread: how to destroy the cookies when the browser is closed?
- Next Thread: Displaying images from mysql database
| Thread Tools | Search this Thread |
ajax apache api array back basic beginner binary broken cakephp checkbox class cms code computing cron curl database date delete display dynamic echo email error external file files filter folder form forms function functions gc_maxlifetime google host href htaccess html iframe image include insert integration ip java javascript joomla limit link login loop mail memmory memory menu mlm multiple mysql navigation oop parsing paypal pdf php problem query question radio random recursion regex remote script search server sessions sms snippet soap source space sql syntax system table thesishelp trouble tutorial update upload url validation validator variable video web xml youtube






