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

Linux, Apache, MySQL, PHP

 
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
AnswerRe: how to change PHP code Pin
Hesham Amin13-Feb-10 21:19
Hesham Amin13-Feb-10 21:19 
GeneralRe: how to change PHP code Pin
wartotojas14-Feb-10 3:25
wartotojas14-Feb-10 3:25 
GeneralRe: how to change PHP code Pin
fly90418-Feb-10 1:30
fly90418-Feb-10 1:30 
GeneralRe: how to change PHP code Pin
wartotojas18-Feb-10 5:52
wartotojas18-Feb-10 5:52 
Questiondevice drivers Pin
ushadv13-Feb-10 4:58
ushadv13-Feb-10 4:58 
AnswerRe: device drivers Pin
Richard MacCutchan13-Feb-10 7:42
mveRichard MacCutchan13-Feb-10 7:42 
AnswerRe: device drivers Pin
markkuk13-Feb-10 11:38
markkuk13-Feb-10 11:38 
Questionhow to open .zip file in php Pin
udch3-Feb-10 7:24
udch3-Feb-10 7:24 
AnswerRe: how to open .zip file in php Pin
Luc Pattyn3-Feb-10 7:29
sitebuilderLuc Pattyn3-Feb-10 7:29 
GeneralRe: how to open .zip file in php Pin
Smithers-Jones5-Feb-10 2:55
Smithers-Jones5-Feb-10 2:55 
QuestionJavascript Menu inside <table> tag</table> Pin
chandni patel2-Feb-10 23:35
chandni patel2-Feb-10 23:35 
AnswerRe: Javascript Menu inside tag Pin
Sujan Dhakal3-Feb-10 2:13
Sujan Dhakal3-Feb-10 2:13 
AnswerRe: Javascript Menu inside tag Pin
cjoki4-Feb-10 7:44
cjoki4-Feb-10 7:44 
Questiongive me some advise for my linxu road! [modified] Pin
wbgxx31-Jan-10 6:36
wbgxx31-Jan-10 6:36 
AnswerRe: give me some advise for my linxu road! Pin
HimanshuJoshi16-Feb-10 2:03
HimanshuJoshi16-Feb-10 2:03 
JokeRe: give me some advise for my linxu road! Pin
Richard MacCutchan16-Feb-10 2:45
mveRichard MacCutchan16-Feb-10 2:45 
GeneralRe: give me some advise for my linxu road! Pin
LloydA1116-Mar-10 12:03
LloydA1116-Mar-10 12:03 

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.