Hi there,
Is it possible to write description about an image without storing it in a db?

I have a photo gallery and instead of using a database, I have used the dir() function to read all the files in the folder then put it in an array.

It works fine but now I want selected images to have description.
For Example:
I have this array of images:
[0] => image1.jpg
[1] => image2.jpg
[2] => image3.jpg
[3] => image4.jpg
[4] => image5.jpg
Now if I want to write description for just [1] and [4] then how do I do that and where will it be stored?

I have read about putting them into a txt file but I don't have a clue where to start!

Another small problem is I want the images to be sorted in date taken! I have read about using the filemtime() function but dont know hoe to use it properley so can someone point me in the right direction.

Hope you guys can help!
Thanks

Jat

Recommended Answers

All 3 Replies

This is what my code looks like:

<?php
include 'includes/functions.inc.php';
$filepath = "files/images/malaysia";
$dirPath = dir($filepath);
$imgArray = array();
while (($file = $dirPath->read()) !== false)
{
  if ((substr($file, -3)=="JPEG") || (substr($file, -3)=="jpg") || (substr($file, -3)=="JPG"))
  {
     $imgArray[ ] = trim($file);
  }
}
$dirPath->close();
sort($imgArray);
$c = count($imgArray);
for($i=0; $i<$c; $i++)
{
	//print_r($imgArray2);
//echo $imgArray[$i];
			echo"<a class='thumb' name='leaf' href='$filepath/$imgArray[$i]'title='Title #1'>";
    echo'<img src="' . $filepath . '/' . $imgArray[$i] . '" width="65px" height="65px" /></a>';
    echo'<div class="caption">
									<div class="image-title"></div>
									<div class="image-desc"></div>';

									
			
			
}
?>
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.