Hey guys, so I have been trying to get images to appear with an SQL query using PHP.

My table has a column called picture, it is datatype nvarchar50. I have a folder in my project called images and in there an image called 4.png. So in the field of my picture column, I have the string, images/4.png.
In my query, I return data from a query and am trying to make an image show with this data, here is my query output code:

while( $row = sqlsrv_fetch_array ( $result, SQLSRV_FETCH_ASSOC))
														{
															echo 'ID number: '.$row['productID'];
															echo '<br/> category: '.$row['category'];
															echo '<br/> product name: '.$row['productName'];
															echo '<br/> Range: '.$row['range'];
															echo '<br/> description: '.$row['description'];
															echo '<br/> size: '.$row['size'];
															echo '<br/> colour: '.$row['colour'];
															echo '<br/> availible: '.$row['available'];
															echo '<br/> price: '.$row['price'];
															echo '<br/> picture: <img  src="'.['picture'].'">;
														
														}

This works, but the last line doesn't, how can I load an image in my query from my project folder, I do not want to store images in the database, just strings linking to the images, can anyone please help me out?

Many thanks!

Member Avatar for diafol
<img  src="'.$row['picture'].'" />;

It works now thanks a lot!

Member Avatar for diafol

OK, mark as solved. :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.