Jump to content

How to pull one image and title with PDO

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

Link to post
Share on other sites

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


<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" />
  <button style="margin-top:7px;" onclick="document.location='cokluresimlisteleformu.php'">Yenile</button>


	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 $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">
	<?php } ?>


Link to post
Share on other sites

Join the conversation

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

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.