Lost Password?

  #1 (permalink)  
Old 05-14-2007, 01:09 PM
Jaan's Avatar   
Jaan Jaan is offline
Moderator
 
Join Date: Dec 2006
Location: Estonia
Age: 17
Posts: 426
Last Blog:
Wadio Media Layout Com...
Rep Power: 9
Jaan will become famous soon enoughJaan will become famous soon enough
Send a message via MSN to Jaan
Default Simple gallery

Hey ya.. i was thinking that i havent submitted any tutorials so.. i must do it now..well today i'm going to show you how you can create your own gallery ^^.. Okay let's start.

Well first, i'm going to create one folder called images and set it's CHMOD to 777. Then i'll make a index file into it because i don't want that some quests are browsing this folder. This index file can be blank or you can use my tutorial where i teach you how to protect your files with one little script Check. Now let's go back to our main directory and let's start with our gallery script. If you want to create a category, then just make a folder into your /images/ folder and name it to "nature" (for example).

Now let's make our category list and let's show how much files are in those categories:

PHP Code:
// Let's get our category name
$cat $_GET['cat'];

function 
categories(){

// Specify your directory were are your categories
$dir opendir("images");

// Now let's get our categories
while (($file readdir($dir)) !== false){

// Let's remove . and .. and index file if there is index file
if($file == "."){
echo 
"";
}elseif(
$file == ".."){
echo 
"";
}elseif(
$file == "index.php"){
echo 
"";
}else{

// Here we are going to find out how much files are in our category
$directory "http://forum.codecall.net/images/$file";
$filecount 0;
$d dir($directory); 
while (
$f $d->read()) { 
 if((
$f!= ".") && ($f!= "..")) { 
 if(!
is_dir($f)) 
 
$filecount++; 
 } 
}
$filecount;

// Display your categories and how much files are in those categories
echo "<a href='index.php?cat=$file'>$file($filecount)</a><br>";
}
}
closedir($dir);


Now we can see all our categories and how many files are in those categories. Now we should make a function what will display our images what are in those categories.

PHP Code:
function images($cat){

// Let's specify our category
$directory "http://forum.codecall.net/images/$cat/";

// If there is not this category what user have entered let's display an error
if(!is_dir($directory)){
die(
"<center><b><font>The category don't exist!</font></b></center>");
}

// Now if everything is okay let's display our images
$dir opendir($directory);
while ((
$file readdir($dir)) == true){

// Let's remove unwanted records like . , .. and index file if there is one
if($file == "."){
echo 
"";
}elseif(
$file == ".."){
echo 
"";
}elseif(
$file == "index.php"){
echo 
"";
}else{

// Show our images what are in our specified category
$url $file;
echo 
"<br>";
echo 
"<a href='images/$cat/$url'><img src='images/$cat/" $file "' border='0' width='135' height='125'></a>";
echo 
"<br><br>";
}
}
closedir($dir);


Now your simple gallery is done. Here is our full script:

PHP Code:
<?php

// Let's get our category name
$cat $_GET['cat'];

function 
categories(){

// Specify your directory were are your categories
$dir opendir("images");

// Now let's get our categories
while (($file readdir($dir)) !== false){

// Let's remove . and .. and index file if there is index file
if($file == "."){
echo 
"";
}elseif(
$file == ".."){
echo 
"";
}elseif(
$file == "index.php"){
echo 
"";
}else{

// Here we are going to find out how much files are in our category
$directory "http://forum.codecall.net/images/$file";
$filecount 0;
$d dir($directory); 
while (
$f $d->read()) { 
 if((
$f!= ".") && ($f!= "..")) { 
 if(!
is_dir($f)) 
 
$filecount++; 
 } 
}
$filecount;

// Display your categories and how much files are in those categories
echo "<a href='index.php?cat=$file'>$file($filecount)</a><br>";
}
}
closedir($dir);

}

function 
images($cat){

// Let's specify our category
$directory "http://forum.codecall.net/images/$cat/";

// If there is not this category what user have entered let's display an error
if(!is_dir($directory)){
die(
"<center><b><font>The category don't exist!</font></b></center>");
}

// Now if everything is okay let's display our images
$dir opendir($directory);
while ((
$file readdir($dir)) == true){

// Let's remove unwanted records like . , .. and index file if there is one
if($file == "."){
echo 
"";
}elseif(
$file == ".."){
echo 
"";
}elseif(
$file == "index.php"){
echo 
"";
}else{

// Show our images what are in our specified category
$url $file;
echo 
"<br>";
echo 
"<a href='images/$cat/$url'><img src='images/$cat/" $file "' border='0' width='135' height='125'></a>";
echo 
"<br><br>";
}
}
closedir($dir);

}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style>
FONT{
font-size:12px;
font-family: Arial, Helvetica, sans-serif;
}
.title{
font-family:Verdana, Arial, Helvetica, sans-serif;
font-size:20px;
font-style: oblique;
}
.cattitle{
font-family:Verdana, Arial, Helvetica, sans-serif;
font-size:15px;
color: #FFFFFF;
}
</style>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>My Gallery</title>
</head>
<body>

<table width="100%" border="1">
<tr>
<td>
<table width="100%" border="1">
<tr>
<td bgcolor="#6699FF"><br><center><font color="#FFFFFF" class="title">My Gallery</font></center><br></td>
</tr>
<tr>
<td bgcolor="#0033FF"><font class="cattitle"><b>Categories</b></font></td>
</tr>
<tr>
<td><?php categories(); ?></td>
</tr>
<tr>
<td>
<center>
<table border="0" width="80%">
<tr>
<td>
<?php images($cat); ?>
</td>
</tr>
</table>
</center>
</td>
</tr>
</table>
</td>
</tr>
</table>

</body>
</html>
I hope it helped. Enjoy.

Regards,
Jaan
__________________


Cheap & Professional Web Design | Need help? Send a PM

Last edited by Jaan; 10-06-2007 at 07:33 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 05-15-2007, 10:21 AM
Jaan's Avatar   
Jaan Jaan is offline
Moderator
 
Join Date: Dec 2006
Location: Estonia
Age: 17
Posts: 426
Last Blog:
Wadio Media Layout Com...
Rep Power: 9
Jaan will become famous soon enoughJaan will become famous soon enough
Send a message via MSN to Jaan
Default

any comments.. maybe?
__________________


Cheap & Professional Web Design | Need help? Send a PM
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 06-11-2007, 03:28 AM
GHOwner GHOwner is offline
Newbie
 
Join Date: Jun 2007
Posts: 6
Rep Power: 0
GHOwner is on a distinguished road
Default

thanks for this! Seems to be a good one. Is there a way to have it make thumbnails too?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 10-06-2007, 07:32 AM
Jaan's Avatar   
Jaan Jaan is offline
Moderator
 
Join Date: Dec 2006
Location: Estonia
Age: 17
Posts: 426
Last Blog:
Wadio Media Layout Com...
Rep Power: 9
Jaan will become famous soon enoughJaan will become famous soon enough
Send a message via MSN to Jaan
Default

yes there is.. i think i will update this tutorial maybe tomorrow or i'm not sure when.. then i'll add that thumbnail thingy ^^
__________________


Cheap & Professional Web Design | Need help? Send a PM
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 11-16-2007, 05:31 AM
xtraze xtraze is offline
Programming God
 
Join Date: Dec 2006
Location: Sri lanka
Posts: 921
Rep Power: 0
xtraze is on a distinguished road
Send a message via MSN to xtraze Send a message via Skype™ to xtraze
Default

I am going to try it on my XAMPP thing.
And I think it will be great to give everyone a DEMO of the Gallery.

So we can see what you mean yourself.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #6 (permalink)  
Old 11-16-2007, 07:04 AM
Jaan's Avatar   
Jaan Jaan is offline
Moderator
 
Join Date: Dec 2006
Location: Estonia
Age: 17
Posts: 426
Last Blog:
Wadio Media Layout Com...
Rep Power: 9
Jaan will become famous soon enoughJaan will become famous soon enough
Send a message via MSN to Jaan
Default

umm.. sure
i'll add demo asap
__________________


Cheap & Professional Web Design | Need help? Send a PM
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 01-11-2008, 09:09 AM
Lunakiri Lunakiri is offline
Newbie
 
Join Date: Jan 2008
Posts: 3
Rep Power: 0
Lunakiri is on a distinguished road
Default

Hmmm, I'm going to have to go try this out!

Thanks =3
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 01-11-2008, 05:05 PM
Jaan's Avatar   
Jaan Jaan is offline
Moderator
 
Join Date: Dec 2006
Location: Estonia
Age: 17
Posts: 426
Last Blog:
Wadio Media Layout Com...
Rep Power: 9
Jaan will become famous soon enoughJaan will become famous soon enough
Send a message via MSN to Jaan
Default

np..
well i don't have hosting.. :/
that's why i can't post a demo :/
sorry mates
__________________


Cheap & Professional Web Design | Need help? Send a PM
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 01-13-2008, 04:41 AM
Lunakiri Lunakiri is offline
Newbie
 
Join Date: Jan 2008
Posts: 3
Rep Power: 0
Lunakiri is on a distinguished road
Default

After I add it to my site (And see if I can do this without screwing things up... >< ) Then I'll post it to be used as a demo 'Kay?

*Goes to try it out*

Edit ::

.. Scratch that, I'm totally useless when it comes to PHP ><

Last edited by Lunakiri; 01-13-2008 at 04:52 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 03-01-2008, 01:43 PM
Whitey's Avatar   
Whitey Whitey is offline
Programmer
 
Join Date: Feb 2008
Location: Loveland, Colorado
Posts: 139
Rep Power: 3
Whitey will become famous soon enoughWhitey will become famous soon enough
Send a message via AIM to Whitey Send a message via MSN to Whitey Send a message via Skype™ to Whitey
Default

Name each PHP section. Your tutorials are great just dont know what to save it as. Like index.php? members.php
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Project: ionFiles - Joomla Simple File Download Jordan Community Projects 290 06-28-2008 10:10 AM
Simple Hex-Editing TcM Tutorials, Classes and Code 12 06-11-2008 05:21 PM
Project: ionFiles - Joomla Simple File Download - Mirror 2 Jordan ionFiles 3 04-07-2008 03:09 PM
Simple counter Jaan PHP Tutorials 4 05-16-2007 01:56 PM
Simple MySQL Database Search Jaan PHP Tutorials 1 01-01-2007 10:15 AM


All times are GMT -5. The time now is 05:33 PM.

Contest Stats

John ........ 87.50000
dargueta ........ 75.00000
Xav ........ 50.00000
MeTh0Dz ........ 20.00000
gaylo565 ........ 18.00000
Johnnyboy ........ 3.00000

Contest Rules

Ads