Im creating a movie database in mysql. i need to store the images of the movie in a table in single field. pls help me out
Don't store images in your database, just store the references to them (file names or paths). If there will be more than one image per movie, then you will have a table representing this one-to-many relation:
CREATE TABLE movie_images (movie_id int, image varchar(255));
For each image, insert a row:
INSERT INTO movie_images (movie_id, image) VALUES (1, 'preview.png');
INSERT INTO movie_images (movie_id, image) VALUES (1, 'poster.png');
INSERT INTO movie_images (movie_id, image) VALUES (1, 'trailer.png');
you can store the images in the db as BLOB. This might help.
The other way (and my preferred one) would be to store the images in the file system and just store the name or the path of the images as string in the db so that you can fetch it later.
精彩评论