Answer the question
In order to leave comments, you need to log in
How would you recommend making a database?
Good day. I have a photography portfolio website. There is an album with pictures in large size and small. What is the best way to make a database, or maybe it's better to write it in php, so that all files from the album are selected, where the small picture will match the big one. At the moment, I have it implemented so that there is a separate field with photo numbers, the numbers correspond to a small and large picture. But there was an idea where php will select the names of pictures from the folder in an array and the corresponding name will be given to a large picture. Since the gallery asks me for the name of a small and large picture. Thanks in advance.
Answer the question
In order to leave comments, you need to log in
When saving to the database and to disk, you can make a unique name, like $fileName = substr(md5(microtime() . uniqid()), 0, 10); Save it to the database and to disk. Save the big picture to the photos folder, and use the Imagine library to the photos/thumbs folder to save a small picture with the same name.
In my table in the table, as a rule, the image field and cropped are stored. They contain the path relative to the root of the project, there is also a file field in which I write the file name and its extension. To process images, write your own class, but rather use a ready-made one, of which there are plenty on the Internet)
The folder structure is something like this:
images/
gallery/
-gallery1/
--thumbs/
---thumb-file.ext, thumb-file.ext, thumb- file.ext, thumb-file.ext, thumb-file.ext,
--file.ext, file.ext,file.ext, file.ext, file.ext, file.ext, file.ext, file.ext, file.ext
-gallery2/
--thumbs/
---thumb-file.ext, thumb-file.ext, thumb-file.ext, thumb-file.ext, thumb-file.ext,
--file.ext, file.ext,file.ext, file.ext, file.ext, file.ext, file.ext, file.ext, file.ext
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question