Jump to content

Recommended Posts

Hi firends, there is a store named "baslik". i try to creating photo gallery. i am saving photo and photo's name in database. Photo's name store named "baslik". 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. "baslik" store's type "varchar" 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. For example when i clicked "meeting" image, it should go other "meeting" images. So, i want to categorize the images.

You can look i put images.


 

resim 6.jpg

resim 7.jpg

So sorry. :) i didn't put the codes.

multipleimagelistingform.php

<h3> Multiple Image Upload </h3>
  <form action="multipleimageprocesspage.php" method="POST" enctype="multipart/form-data">
  <!--<span> Add Title </span><br>
  <input type="text" name="coklubasliklistele" /><br><br>-->
  
  <span> Add Title </span><br>
  <input type="text" name="baslik"><br><br>
  
  <!--<span> Resim Id </span><br>
  <input type="number" name="resim_id"><br><br>-->
  
  <span> Image Upload </span>&nbsp;&nbsp; <br>
  <input type="file" name="files[]" multiple><br>
  <input type="submit" value="Yükle" name="submit" />
  </form>
  <button style="margin-top:7px;" onclick="document.location='cokluresimlisteleformu.php'">Yenile</button>

multipleimageprocesspage.php

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

	<?php
 
if(isset($_POST['submit'])){

	$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
  for($i=0;$i<$countfiles;$i++){
	
    // 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
       if(move_uploaded_file($_FILES['files']['tmp_name'][$i],$target_file)){

          // Execute query
	  $statement->execute(array($filename,$target_file,$baslik,$resimid));

       }
    }
 
  }
  
  echo "File upload successfully";
}
?>

image-gallery.php

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

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

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.