'adding jpg image from mysql to html

Just to preface im very new to this so this might be a dumb question but...

I am trying to design a website pulling from a database where i've stored the product info for the 'shop'. This is the code i have so far.

session_start();

include("connections.php");

$con = mysqli_connect($servername, $username, $password, $database);

$sql="SELECT product_title, product_desc, product_image, product_price, product_type FROM tbl_products";

$results=mysqli_query($con, $sql);

if(mysqli_num_rows($results) > 0) {

    while($row=mysqli_fetch_array($results)) {
     echo $row[0];
     echo "<br>";
     echo $row[1];
     echo "<br>";
     echo $row[2];
     echo "<br>";
     echo $row[3];
     echo "<br>";
     echo $row[4];
     echo "<br>";
     
     }
}

mysqli_close($con);

?>

It works fine at displaying the info however rather than displaying the image its just displaying the file name e.g. hoodie(1).jpg. I assume i need to save the images to the database or to the folder but i tried putting them in my code folder and they still dont show up, any ideas?



Solution 1:[1]

To display the image use: echo '<img src="'.$row[2].'" alt="" />';

To upload a image, learn file uploading: https://www.tutorialspoint.com/php/php_file_uploading.htm

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Kip