Hi i'm looking to create a dynamic website that allows me to showcase my personal picture collection.

I want a table in a MySQL database that has the fields:

-Image ID
-Image Name
-Actualimage
-Description
-Date Added
-Views

then i want a PHP script that creates a page (i assume by passing parameters in the URL)

so i want to make lots of dynamic pages that load with the selected image on obviously without having to make hundereds to seperate pages.

so basically the user selects a picture by a thumbnail on the homepage, it references the image ID and produces a page with the larger image along with the description thats unique to that image.

Thanks

Dani AI

Generated

If you want a lightweight, roll-your-own gallery (as an alternative to and @diafol’s Coppermine suggestion), keep images on disk and store only metadata in MySQL. Your table can be: id (PK), filename (path to the full-size image), title, description, added_at (DATETIME), views (INT). This avoids BLOBs, keeps backups simple, and makes thumbnail generation fast. Thumbnails live in /thumbs; full images in /uploads. The homepage lists thumbnails that link to a single script like image.php?id=123.

Here is a minimal, safe image page using PDO and prepared statements. It fetches metadata, increments views, and outputs the image and description.

<?php
// image.php
$pdo = new PDO('mysql:host=localhost;dbname=gallery;charset=utf8mb4','user','pass',[
  PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
]);

$id = filter_input(INPUT_GET, 'id', FILTER_VALIDATE_INT);
if (!$id) { http_response_code(404); exit('Not found'); }

$stmt = $pdo->prepare('SELECT id, filename, title, description, views FROM images WHERE id = ?');
$stmt->execute([$id]);
$img = $stmt->fetch(PDO::FETCH_ASSOC);
if (!$img) { http_response_code(404); exit('Not found'); }

$pdo->prepare('UPDATE images SET views = views + 1 WHERE id = ?')->execute([$id]);
?>
<h1><?php echo htmlspecialchars($img['title'], ENT_QUOTES, 'UTF-8'); ?></h1>
<img src="/uploads/<?php echo rawurlencode($img['filename']); ?>"
     alt="<?php echo htmlspecialchars($img['title'], ENT_QUOTES, 'UTF-8'); ?>">
<p><?php echo nl2br(htmlspecialchars($img['description'], ENT_QUOTES, 'UTF-8')); ?></p>
<p>Views: <?php echo $img['views'] + 1; ?></p>

Practical tips:

  • Generate and cache thumbnails server-side (GD or Imagick) at upload time to keep pages snappy.
  • Escape all output (as above) and validate IDs to prevent XSS/SQLi.
  • Add pagination on the homepage and an index on added_at for fast sorting.
  • Optional: pretty URLs with a rewrite to /image/123 or /image/title-123.
  • For turnkey features (albums, user auth), ’s and ’s suggestions are solid; for a simple personal gallery, the DIY approach above is enough.

Recommended Answers

All 7 Replies

You can also use the Different scripts that are available on the web.
I basically use the coppermine which has various features in it.

Hi i'm looking to create a dynamic website that allows me to showcase my personal picture collection.

I want a table in a MySQL database that has the fields:

-Image ID
-Image Name
-Actualimage
-Description
-Date Added
-Views

then i want a PHP script that creates a page (i assume by passing parameters in the URL)

so i want to make lots of dynamic pages that load with the selected image on obviously without having to make hundereds to seperate pages.

so basically the user selects a picture by a thumbnail on the homepage, it references the image ID and produces a page with the larger image along with the description thats unique to that image.

Thanks

Did you have a look at this ?

Member Avatar for Member #120589

Coppermine has all the functionality you need (and more). However, it's quite a big app if you just want a simple gallery script.

how to use coppermine by the way??because i have downloaded many zipped codes from various websites

Member Avatar for Member #120589

how to use coppermine by the way??because i have downloaded many zipped codes from various websites

This is a reply to a 3 year old thread. Are you asking how to use Coppermine? Have you installed it and read the site's documentation? If not, perhaps you could start with that. If you have, please be more specific with your needs. "How to use Coppermine" is not something that can be easily answered - there's a whole manual on it out there.

this is helpfull information

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.