Photo Gallery Content Management System
- Code for Photo Gallery Navigation
- Code for Photo Gallery—View
- Code for Photo Gallery—Create
- Code for Photo Gallery—Add Category
- Code for Photo Gallery—Delete Category
- Code for Photo Gallery—Add Photo
- Code for Photo Gallery—Delete Photo
There are scripts that use methods like caching, file_get_contents, php_sapi_name, apache_request_headers, timestamps, blob fields, fopen(), fclose(), fgets(), fwrite(), file(), etc., for managing photos, but this is not such a script. Our host is really fussy about allowing this stuff so we settled for creating writing, reading, and editing scripts that simply keep all the photo names and category names organized in a MySQL database, rather than trying to actually store the pictures on the server in a db as data. Let's face it, the MySQL blob storage way is less safe, slower to use than just simply displaying images in browsers in Web pages, as well as being a bigger hassle to program. And by default, PHP does not allow uploading files larger than 2Mb, without messing with directives which our host would not allow. (Can you say "security risk"?) Our way, on this page, will allow images larger than 2Mb, and loading images into online folders is easier than blob storage. In either case, the images are on the server. But in one case there are restrictions, dangers, and hassles. And delays. Not with our way. And our way has a cool thumbnail display routine where you need not click on a thumbnail image to get a bigger image—hovering does the job. If you prefer clicking, dump the mouse coordinate reading and just install onclick events on each thumbnail.
This assumes you have a MySQL database you can use and permissions and you know the connection data and it's in a config.php file you've edited with your own data, and that you have copied the navi.html file below and uploaded it. (Do not add anything to this HTML file—it's an include file that does NOT need anything else!) Read the names in it and see the tutorial files on each of these—make sure you grab the code from each of these and name them the name in the navi.html file below and save and upload all of them.