gilabola Posted April 2, 2010 Share Posted April 2, 2010 Product Image : <img src="upload/<?php echo $row1["PRO_IMAGE"]; ?>.jpg" /> Hello! Can someone show me the correct way to retrieve the image file name from mysql table so that it can be display on the browser? The image file is located in the folder upload. The file name of the image is .5212 yes its with dot on the beginning of the file name Thank you [attachment deleted by admin] Link to comment https://forums.phpfreaks.com/topic/197316-help-displaying-image-in-php/ Share on other sites More sharing options...
Lukeidiot Posted April 2, 2010 Share Posted April 2, 2010 Product Image : <img src="upload/<?php echo $row1["PRO_IMAGE"]; ?>.jpg" /> Hello! Can someone show me the correct way to retrieve the image file name from mysql table so that it can be display on the browser? The image file is located in the folder upload. The file name of the image is .5212 yes its with dot on the beginning of the file name Thank you Try this: (make sure you change "table" to your table name, and correct db connection info) <?php mysql_connect('localhost','dbuser','dbpass'); mysql_select_db('database_name'); $sql = mysql_query("SELECT * FROM table ORDER BY PRO_ID asc"); while($row = mysql_fetch_assoc($sql)){ echo "Product Image: <img src='$row[PRO_NAME]'/>"; ?> } Link to comment https://forums.phpfreaks.com/topic/197316-help-displaying-image-in-php/#findComment-1035687 Share on other sites More sharing options...
gilabola Posted April 2, 2010 Author Share Posted April 2, 2010 The database connection is ok. $x = 0; while($row1=mysql_fetch_assoc($result1)) { ?> <p><strong>Product ID</strong><?php echo $row1["PRO_ID"]; ?></p> <p><strong>Product Name</strong><?php echo $row1["PRO_NAME"]; ?></p> <p><strong>Product Price</strong>RM<?php echo $row1["PRO_PRICE"]; ?></p> <p><strong>Product Quantity</strong><?php echo $row1["PRO_QUANTITY"]; ?></p> <p><strong>Product Description</strong><?php echo $row1["PRO_DESCRIPTION"]; ?></p> <p><strong>Product Image</strong><img src="upload/<?php echo $row1["PRO_IMAGE"];?>.jpg" /></p> <?php $x++; } ?> PRO_ID,PRO_NAME,PRO_PRICE,PRO_QUANTITY,PRO_DESCRIPTION values can be display perfectly. the only problem is on the image link. Link to comment https://forums.phpfreaks.com/topic/197316-help-displaying-image-in-php/#findComment-1035694 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.