I was implementing an image gallery from one of tutorials. In this tutorial PHP opens a directory and loops through it and outputs all image files. I am looking for code solution how to change this loop to output only those images that belongs to particular image album. There should be way to run SQL query and select files and then output them, problem is I have no idea how.
When I upload image I store some data to following table:
CREATE TABLE tbl_image (
im_id INT NOT NULL AUTO_INCREMENT,
im_user_name VARCHAR(25) NOT NULL,
im_album_id INT NOT NULL,
im_title VARCHAR(64) NOT NULL,
im_description TEXT NOT NULL,
im_type VARCHAR(30) NOT NULL,
im_image VARCHAR(60) NOT NULL,
im_date DATETIME NOT NULL,
here is the code piece that should be changed:
/* Configuration Start */
$thumb_directory = 'img/thumbs';
$orig_directory = 'img/original';
$stage_width=600; // How big is the area the images are scattered on
/* Configuration end */
/* Opening the thumbnail directory and looping through all the thumbs: */
$dir_handle = @opendir($thumb_directory) or die("There is an error with your image directory!");
while ($file = readdir($dir_handle))
/* Skipping the system files: */if($file=='.' || $file == '..') continue;
$file_parts = explode('.',$file);
$ext = strtolower(array_pop($file_parts));
/* Using the file name (withouth the extension) as a image title: */
$title = implode('.',$file_parts);
$title = htmlspecialchars($title);
/* If the file extension is allowed: */if(in_array($ext,$allowed_types))
/* Generating random values for the position and rotation: */
$rot = rand(-40,40);
if($top>$stage_height-130 && $left > $stage_width-230)
/* Prevent the images from hiding the drop box */
/* Outputting each image: */
<div id="pic-'.($i++).'" class="pic" style="top:'.$top.'px;left:'.$left.'px;background:url('.$thumb_directory.'/'.$file.') no-repeat 50% 50%; -moz-transform:rotate('.$rot.'deg); -webkit-transform:rotate('.$rot.'deg);">
<a class="fancybox" rel="fncbx" href="'.$orig_directory.'/'.$file.'" target="_blank">'.$title.'</a>
/* Closing the directory */
any thoughts or suggestions are appreciated.
Luc Pattyn [Forum Guidelines][Why QA sucks][My Articles] I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. [The QA section does it automatically now, I hope we soon get it on regular forums as well]
1. Set page encoding (UTF-8)
2. The text page should be about 5-7% of your keywords.
3. Apply with <strong> these keywords
4. If your site is new, it is in the sandbox Google - must wait until released from the sandbox.
Take these simple steps and you will get an answer to many of your questions.
More information - html tutorials
hey, ok its going to take some time for some data to arrive such as links, search terms etc, also on the right hand side of the webmaster tools page you can change the time range from 7days to dec, jan etc.