-5

I'm working on a side project, and practicing my SQL queries. My question is how do I insert an image file into this query I have? Never had to or been shown how to do it before.

INSERT INTO products (prod_category,prod_title,image,conditions,in_stock,price,description) VALUES ("gaming tower",   ,"used","yes",500,"new gaming tower");

Just to add, I'm just curious to the method, and using phpMyAdmin.

Francisco
  • 10,918
  • 6
  • 34
  • 45
Nick Beck
  • 17
  • 7

1 Answers1

1

It's not a best practice to store images in database. It's heavy, increases needed space, is not practical because you need to parse it for displaying.

More simple is the following approach:

  • Upload your file (you've already)
  • Store your file on disk
  • Store the path to file in your database
  • Display your image with basic html <img src="">. The src attribute can be filled with the stored path from your database
schellingerht
  • 5,726
  • 2
  • 28
  • 56