Jump to content

HELP! displaying image in php


gilabola

Recommended Posts

	

     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

	

     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]'/>";
?>
}

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.

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.