benidopogi Posted November 15, 2014 Share Posted November 15, 2014 (edited) hi to all.Im currently displaying the images from my upload directory but the image does not display.please help thanks <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <form enctype="multipart/form-data"> <?php include 'connect.php'; $dir = '/images/advisory'; $res = mysql_query("Select * from image_advisory INNER JOIN main_advisory ON image_advisory.advisory_id = main_advisory.id "); echo"<table border='1px'>"; while($row=mysql_fetch_array($res)) { echo"<tr>"; echo"<td>"; echo $row['advisory']; echo "</td>"; echo"<td>";?><img src="<?php echo images/advisory/'.$row["ad_img"].'; ?>" height="100" width ="100" > <?php echo "</td>";//this is the error please help echo"</tr>"; } echo "</table>"; ?> </form> </body> </html> Edited November 15, 2014 by benidopogi Quote Link to comment https://forums.phpfreaks.com/topic/292475-display-image-from-uploaded-directory-php-mysql/ Share on other sites More sharing options...
Barand Posted November 15, 2014 Share Posted November 15, 2014 It may be the relative directory path. You have defined $dir = '/images/advisory'; but in your img tags you use "images/advisory" without the preceding "/". Also, why the <form> tags when you have no form inputs? Quote Link to comment https://forums.phpfreaks.com/topic/292475-display-image-from-uploaded-directory-php-mysql/#findComment-1496635 Share on other sites More sharing options...
tryingtolearn Posted November 15, 2014 Share Posted November 15, 2014 your img tag also is missing the opening ' and closing ' <?php echo images/advisory/'.$row["ad_img"].'; ?> maybe try <?php echo '/images/advisory/'.$row['ad_img'].''; ?> View the output source and see what you are getting as the image path. Might be a good place to start tracking the problem. Quote Link to comment https://forums.phpfreaks.com/topic/292475-display-image-from-uploaded-directory-php-mysql/#findComment-1496637 Share on other sites More sharing options...
QuickOldCar Posted November 15, 2014 Share Posted November 15, 2014 (edited) You can do the multiple echo with one also eliminating the need to keep breaking in and out of php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR...nsitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <form enctype="multipart/form-data"> <?php include 'connect.php'; $dir = '/images/advisory'; $res = mysql_query("Select * from image_advisory INNER JOIN main_advisory ON image_advisory.advisory_id = main_advisory.id "); echo "<table border='1px'>"; while ($row = mysql_fetch_array($res)) { echo "<tr>"; echo "<td>" . $row['advisory'] . "</td>"; echo "<td><img src='" . $dir . "/" . $row['ad_img'] . "' height='100' width ='100' ></td>"; echo "</tr>"; } echo "</table>"; ?> </form> </body> </html> Edited November 15, 2014 by QuickOldCar Quote Link to comment https://forums.phpfreaks.com/topic/292475-display-image-from-uploaded-directory-php-mysql/#findComment-1496647 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.