Click here to Skip to main content
15,921,351 members
Home / Discussions / Linux, Apache, MySQL, PHP
   

Linux, Apache, MySQL, PHP

 
Questionquestion on php imap_open, base64_decode and csv file attachments Pin
cjoki25-Feb-10 6:39
cjoki25-Feb-10 6:39 
AnswerRe: question on php imap_open, base64_decode and csv file attachments Pin
Graham Breach25-Feb-10 7:33
Graham Breach25-Feb-10 7:33 
GeneralRe: question on php imap_open, base64_decode and csv file attachments Pin
cjoki25-Feb-10 10:00
cjoki25-Feb-10 10:00 
Questionwhy not submit Pin
KARFER25-Feb-10 2:04
KARFER25-Feb-10 2:04 
AnswerRe: why not submit Pin
Marc Firth25-Feb-10 2:29
Marc Firth25-Feb-10 2:29 
GeneralRe: why not submit Pin
KARFER25-Feb-10 4:33
KARFER25-Feb-10 4:33 
GeneralRe: why not submit Pin
cjoki25-Feb-10 6:20
cjoki25-Feb-10 6:20 
Questionhow to unzip files on unix that are zipped on windows Pin
msubbaraodba25-Feb-10 0:56
msubbaraodba25-Feb-10 0:56 
AnswerRe: how to unzip files on unix that are zipped on windows Pin
MatrixCoder27-Feb-10 16:10
MatrixCoder27-Feb-10 16:10 
QuestionAd insertion technique Pin
booota24-Feb-10 22:59
booota24-Feb-10 22:59 
QuestionRetrieving images from mysql database n display using php Pin
sarang_k21-Feb-10 22:32
sarang_k21-Feb-10 22:32 
AnswerRe: Retrieving images from mysql database n display using php Pin
Graham Breach21-Feb-10 23:27
Graham Breach21-Feb-10 23:27 
Questionsolve my code Pin
itishree parida20-Feb-10 17:34
itishree parida20-Feb-10 17:34 
AnswerRe: solve my code Pin
cjoki25-Feb-10 6:44
cjoki25-Feb-10 6:44 
QuestionHow to redirect ? Pin
udch20-Feb-10 3:14
udch20-Feb-10 3:14 
AnswerRe: How to redirect ? Pin
fly90420-Feb-10 5:33
fly90420-Feb-10 5:33 
GeneralRe: How to redirect ? Pin
udch20-Feb-10 7:00
udch20-Feb-10 7:00 
Questionhelp me translate site german to english Pin
ariodoni19-Feb-10 22:45
ariodoni19-Feb-10 22:45 
AnswerRe: help me translate site german to english Pin
abushahin23-Feb-10 13:09
abushahin23-Feb-10 13:09 
QuestionProblem with double quote Pin
sarang_k15-Feb-10 19:08
sarang_k15-Feb-10 19:08 
AnswerRe: Problem with double quote Pin
Graham Breach15-Feb-10 21:21
Graham Breach15-Feb-10 21:21 
QuestionPostback in php Pin
sarang_k15-Feb-10 0:24
sarang_k15-Feb-10 0:24 
AnswerRe: Postback in php Pin
EliottA15-Feb-10 2:41
EliottA15-Feb-10 2:41 
AnswerRe: Postback in php Pin
DmiNi17-Feb-10 6:30
DmiNi17-Feb-10 6:30 
Questionhow to change PHP code Pin
wartotojas13-Feb-10 9:57
wartotojas13-Feb-10 9:57 
Hi everybody,
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,
PRIMARY KEY(im_id)
);


here is the code piece that should be changed:
<?php

/* Configuration Start */

$thumb_directory = 'img/thumbs';
$orig_directory = 'img/original';

$stage_width=600;	// How big is the area the images are scattered on
$stage_height=400;

/* Configuration end */

$allowed_types=array('jpg','jpeg','gif','png');
$file_parts=array();
$ext='';
$title='';
$i=0;

/* 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!");

$i=1;
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: */
		$left=rand(0,$stage_width);
		$top=rand(0,400);
		$rot = rand(-40,40);
		
		if($top>$stage_height-130 && $left > $stage_width-230)
		{
			/* Prevent the images from hiding the drop box */
			$top-=120+130;
			$left-=230;
		}
		
		/* Outputting each image: */
		
		echo '
		<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>
		</div>';
	}
}

/* Closing the directory */
closedir($dir_handle);

?>


any thoughts or suggestions are appreciated.
Thanks

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.