I want to create image gallery

Hi firends, i have a problem. i try to creating photo gallery. i am saving photo and photo’s name in database. Now, For example i am saving called “Summer Photos”. i saved 10 photos. When i pull the images and names, all photos and names are pulling. I want to pull one image and its name from “baslik” store. When i click the image’s name, it should post other “Summer Photos”. Image gallery should creating next to next like 1. image. And When i clicked the image, other images should open like 2. image. For example when i clicked “meeting” image, it should go other “meeting” images. So, i want to categorize the images.

multipleimagelistingform.php // i didn’t put “html” codes then i put image intead of it.


	include "../../../baglanti.php";


	$baslik = $_POST['baslik'];
	$resimid = $_POST['resim_id'];

  // Count total files
  $countfiles = count($_FILES['files']['name']);
  // Prepared statement
  $query = "INSERT INTO cokluresimlistele (cokluresimlistele_resim, cokluresimlistele_baslik, baslik, resim_id) VALUES(?,?,?,?)";

  $statement = $db->prepare($query);

  // Loop all files
    // File name
    $filename = $_FILES['files']['name'][$i];
    // Location
    $target_file = '../../../upload/cokluresimlistele/'.$filename;
    // file extension
    $file_extension = pathinfo($target_file, PATHINFO_EXTENSION);
    $file_extension = strtolower($file_extension);

    // Valid image extension
    $valid_extension = array("png","jpeg","jpg");

    if(in_array($file_extension, $valid_extension)){

       // Upload file

          // Execute query

       echo "File upload successfully";


         <?php include "baglanti.php"; ?>

	$resim = $db->query("SELECT * FROM cokluresimlistele");
	foreach($resim as $resimal) {
	<div class="resim">
	<img src='upload/cokluresimlistele/<?php echo $resimal["cokluresimlistele_resim"]; ?>' />
	<div class="resimyazisi"><a href='admin/panel/production/cokluresimlistele.php'><?php echo $resimal["baslik"]; ?></a></div>
	<div class="silduzenle">
	<?php } ?>

First of all I would NOT save the images to the database table, but rather the path and image name to the db table. While I don’t upload multiple images at one time that is what I do. You will really bog down the database table uploading images. It’s bad enough saving large files to a directory.

Here’s a small snippet of my upload script.

     * Create unique names for thumbnail and large image.
    $new_thumb_name = $thumb_path . 'thumb-gallery-' . time() . '.' . $file_ext;
    $new_file_name = $dir_path . 'img-gallery-' . time() . '.' . $file_ext;

     * Set path information for database table.
    $data['thumb_path'] = $new_thumb_name;
    $data['image_path'] = $new_file_name;

     * Call resize function to set the thumbnails and large images
     * to the correct size and save them to their corresponding
     * directories.
    $thumb_result = resize($thumb_tmp, $new_thumb_name, true);
    $save_result = resize($file_tmp, $new_file_name);

     * If no errors save ALL the information to the
     * database table.
    if (empty($errors) === true) {
        /* Save to Database Table CMS */
        $cms = new CMS($data);
        $result = $cms->create();
        if ($result) {
            header("Location: index.php");
    } else {
        return $errors;

and my MySQL database Table

create table cms
    id           int auto_increment
        primary key,
    user_id      int                          null,
    author       varchar(160)                 null,
    thumb_path   varchar(255)                 null,
    image_path   varchar(255)                 null,
    Model        varchar(255)                 null,
    ExposureTime varchar(255)                 null,
    Aperture     varchar(255)                 null,
    ISO          varchar(255)                 null,
    FocalLength  varchar(255)                 null,
    heading      varchar(60)                  null,
    content      text collate utf8_unicode_ci null,
    date_updated datetime                     null,
    date_added   datetime                     null

If you do save the images to the table, I believe it has to be a blob. However, like I said I don’t do it that way and the only way I would even think about doing it is if I were a large company or had a very specialized need to be doing this way. In my opinion an image gallery isn’t one of them.

i don’t save the images to the database. Only path and title. I am just pulling “multipleimagelisting_image” and “title”. i uploaded the images “upload/images/” in folder. i want to be like below.

You posted so much…

whats your question?

Or more so… lets start with your FIRST question…

I want to do listing next to next. And when i clicked the image, other photos should open. You can look up.

My problem haven’t solved yet. No one answering? :slight_smile:

Sponsor our Newsletter | Privacy Policy | Terms of Service