add jpg image from mysql to html
P粉511757848
P粉511757848 2024-04-02 13:27:34
0
1
427

As a preface, I'm very new to this so this may be a stupid question, but...

I'm trying to design a website that pulls from a database where I store product information for a "store". This is my code 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 displays the information fine, but instead of displaying the image, it only displays the filename, for example hoodie(1).jpg. I'm assuming I need to save the images to a database or a folder, but I've tried putting them into my code folder and they still don't show up, any ideas?

P粉511757848
P粉511757848

reply all(1)
P粉458725040

To display an image, use: echo '';

To upload images, please learn file upload: https://www.tutorialspoint.com/php/php_file_uploading.htm

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template