fotogallerij met album
Auteur: PeeZz - 25 maart 2006 - 19:23 - Gekeurd door: nemesiskoen - Hits: 18419 - Aantal punten: 2.50 (5 stemmen)
album.php - weergave van de albums in je table
fotos.php - weergave van de fotos van het geselecteerde album
toevoegen.php - fotos toevoegen
bij het voorbeeld heb ik maar één album!
MySQL:
mysql_query("create table foto(
id int not null auto_increment,
primary key(id),
album varchar(100),
naam varchar(200),
bestand varchar(200))")
or die (mysql_error());
changelog:
26-06-2006
Action in toevoegen.php veranderd van index.php?p=fotos/toevoegen naar toevoegen.php n.a.v. dit forumbericht.
|
Code: |
album.php
<table cellspacing="0" cellpadding="0" border="0" width="100%" height="100%">
<tr>
<td align="center" height="20" width="75%" style="border-bottom: 1px solid #1ab4e1">fotoalbums</td>
<td align="center" width="15%" style="border-left: 1px solid #1ab4e1; border-bottom: 1px solid #1ab4e1">
<?
$maand = array("niet", "januari", "februari", "maart", "april", "mei", "juni", "juli", "augustus", "september", "oktober", "november", "december");
$j = date("j");
$n = date("n");
$Y = date("Y");
echo $j." ".$maand[$n]." ".$Y;
?>
</td>
</tr>
<tr>
<td colspan="2">
<table cellspacing="0" cellpadding="0" border="0" width="100%">
<tr>
<td width="10" />
<td>
<table cellspacing="0" cellpadding="0" border="0" width="100%">
<tr>
<?
$afbeelding = 0;
$select = "SELECT * FROM foto group by album";
$query = mysql_query($select);
while ($list = mysql_fetch_object($query))
{
if ($afbeelding < 4 ) //4 afb per rij
{
echo '<td width="25%"><a href="index.php?p=fotos/fotos&album='.$list->album.'"><img src="fotos/'.$list->album.'/'.$list->bestand.'"height="75" /></a><br />'.$list->album.'</td>';
}
else
{
echo '</tr><tr><td width="25%"><a href="fotos/fotos$album='.$list->album.'"><p><img src="fotos/'.$list->album.'/'.$list->bestand.'" height="75" /></a></td>';
$afbeelding = 0;
}
$afbeelding++;
}
?>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing="0" cellpadding="0" border="0" width="100%" height="100%"> <tr> <td align="center" height="20" width="75%" style="border-bottom: 1px solid #1ab4e1">fotoalbums</td> <td align="center" width="15%" style="border-left: 1px solid #1ab4e1; border-bottom: 1px solid #1ab4e1"> <? $maand = array("niet", "januari", "februari", "maart", "april", "mei", "juni", "juli", "augustus", "september", "oktober", "november", "december"); echo $j." ".$maand[$n]." ".$Y; ?> </td> </tr> <tr> <td colspan="2"> <table cellspacing="0" cellpadding="0" border="0" width="100%"> <tr> <td width="10" /> <td> <table cellspacing="0" cellpadding="0" border="0" width="100%"> <tr> <? $afbeelding = 0; $select = "SELECT * FROM foto group by album"; { if ($afbeelding < 4 ) //4 afb per rij { echo '<td width="25%"><a href="index.php?p=fotos/fotos&album='.$list->album.'"><img src="fotos/'.$list->album.'/'.$list->bestand.'"height="75" /></a><br />'.$list->album.'</td>'; } else { echo '</tr><tr><td width="25%"><a href="fotos/fotos$album='.$list->album.'"><p><img src="fotos/'.$list->album.'/'.$list->bestand.'" height="75" /></a></td>'; $afbeelding = 0; } $afbeelding++; } ?> </tr> </table> </td> </tr> </table> </td> </tr> </table>
fotos.php
<table cellspacing="0" cellpadding="0" border="0" width="100%" height="100%">
<tr>
<td align="center" height="20" width="75%" style="border-bottom: 1px solid #1ab4e1"><? echo $_GET['album']; ?></td>
<td align="center" width="15%" style="border-left: 1px solid #1ab4e1; border-bottom: 1px solid #1ab4e1">
<?
$maand = array("niet", "januari", "februari", "maart", "april", "mei", "juni", "juli", "augustus", "september", "oktober", "november", "december");
$j = date("j");
$n = date("n");
$Y = date("Y");
echo $j." ".$maand[$n]." ".$Y;
?>
</td>
</tr>
<tr>
<td colspan="2">
<table cellspacing="0" cellpadding="0" border="0" width="100%">
<tr>
<td width="10" />
<td>
<table cellspacing="0" cellpadding="0" border="0" width="100%">
<tr>
<?
$album = $_GET['album'];
if(isset($_POST['delf']))
{
$select = "SELECT * FROM foto where album='$album'";
$query = mysql_query($select);
while($dellist = mysql_fetch_object($query))
{
$delid = "del".$dellist->id;
if($_POST[$delid] == 'delete')
{
$bestand = "./fotos/".$dellist->album."/".$dellist->bestand;
unlink($bestand);
$delq = "delete from foto where id=".$dellist->id;
mysql_query($delq);
}
}
}
if(isset($_SESSION['Login']))
{
echo "<form action=\"index.php?p=fotos/fotos&album=".$_GET['album']."\" method=\"post\">";
}
$afbeelding = 0;
$select = "SELECT * FROM foto where album='$album'";
$query = mysql_query($select);
while ($list = mysql_fetch_object($query))
{
if ($afbeelding < 4 ) //4 afb per rij
{
echo '<td width="25%"><a target="_blank" href="fotos/'.$list->album.'/'.$list->bestand.'"><img src="fotos/'.$list->album.'/'.$list->bestand.'"height="75" /></a>';
if(isset($_SESSION['Login']))
{
echo "<input type=\"checkbox\" name=\"del".$list->id."\" value=\"delete\" />";
}
echo '</td>';
}
else
{
echo '</tr><tr><td width="25%"><a target="_blank" href="fotos/'.$list->album.'/'.$list->bestand.'"><img src="fotos/'.$list->album.'/'.$list->bestand.'" height="75" /></a>';
if(isset($_SESSION['Login']))
{
echo "<input type=\"checkbox\" name=\"del".$list->id."\" value=\"delete\" />";
}
echo '</td>';
$afbeelding = 0;
}
$afbeelding++;
}
?>
</tr>
<?
if(isset($_SESSION['Login']))
{
echo '<tr><td><input type="submit" name="delf" value="Fotos verwijderen" /></form></td></tr>';
}
?>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing="0" cellpadding="0" border="0" width="100%" height="100%"> <tr> <td align="center" height="20" width="75%" style="border-bottom: 1px solid #1ab4e1"> <? echo $_GET['album']; ?></td> <td align="center" width="15%" style="border-left: 1px solid #1ab4e1; border-bottom: 1px solid #1ab4e1"> <? $maand = array("niet", "januari", "februari", "maart", "april", "mei", "juni", "juli", "augustus", "september", "oktober", "november", "december"); echo $j." ".$maand[$n]." ".$Y; ?> </td> </tr> <tr> <td colspan="2"> <table cellspacing="0" cellpadding="0" border="0" width="100%"> <tr> <td width="10" /> <td> <table cellspacing="0" cellpadding="0" border="0" width="100%"> <tr> <? $album = $_GET['album']; if(isset($_POST['delf'])) { $select = "SELECT * FROM foto where album='$album'"; { $delid = "del".$dellist->id; if($_POST[$delid] == 'delete') { $bestand = "./fotos/".$dellist->album."/".$dellist->bestand; $delq = "delete from foto where id=".$dellist->id; } } } if(isset($_SESSION['Login'])) { echo "<form action=\"index.php?p=fotos/fotos&album=".$_GET['album']."\" method=\"post\">"; } $afbeelding = 0; $select = "SELECT * FROM foto where album='$album'"; { if ($afbeelding < 4 ) //4 afb per rij { echo '<td width="25%"><a target="_blank" href="fotos/'.$list->album.'/'.$list->bestand.'"><img src="fotos/'.$list->album.'/'.$list->bestand.'"height="75" /></a>'; if(isset($_SESSION['Login'])) { echo "<input type=\"checkbox\" name=\"del".$list->id."\" value=\"delete\" />"; } } else { echo '</tr><tr><td width="25%"><a target="_blank" href="fotos/'.$list->album.'/'.$list->bestand.'"><img src="fotos/'.$list->album.'/'.$list->bestand.'" height="75" /></a>'; if(isset($_SESSION['Login'])) { echo "<input type=\"checkbox\" name=\"del".$list->id."\" value=\"delete\" />"; } $afbeelding = 0; } $afbeelding++; } ?> </tr> <? if(isset($_SESSION['Login'])) { echo '<tr><td><input type="submit" name="delf" value="Fotos verwijderen" /></form></td></tr>'; } ?> </table> </td> </tr> </table> </td> </tr> </table>
toevoegen.php
<table cellspacing="0" cellpadding="0" border="0" width="100%" height="100%">
<tr>
<td align="center" height="20" width="75%" style="border-bottom: 1px solid #1ab4e1">foto toevoegen</td>
<td align="center" width="15%" style="border-left: 1px solid #1ab4e1; border-bottom: 1px solid #1ab4e1">
<?
$maand = array("niet", "januari", "februari", "maart", "april", "mei", "juni", "juli", "augustus", "september", "oktober", "november", "december");
$j = date("j");
$n = date("n");
$Y = date("Y");
echo $j." ".$maand[$n]." ".$Y;
?>
</td>
</tr>
<tr>
<td colspan="2">
<table cellspacing="0" cellpadding="0" border="0" width="100%">
<tr>
<td width="10"></td>
<td valign="top">
<?
if(isset($_POST['fototoev']))
{
$naam = basename($_FILES['bestand']['name']);
$ext = substr($naam,strlen($naam)-4);
if( !strcasecmp($ext, '.jpg') || !strcasecmp($ext, '.gif') )
{
if($_FILES['bestand']['name'] == '' || $_FILES['bestand']['size'] >= '1000000')
{
if($_FILES['bestand']['name'] == '')
{
echo "U hebt geen bestand geselecteerd!";
}
else
{
echo "Het bestand is te groot!";
}
}
else
{
if($_POST['album'] == 1)
{
$album = $_POST['salbum'];
}
else
{
$album = $_POST['nalbum'];
$ndir = "fotos/".$album;
mkdir($ndir,0777);
}
$dir = "fotos/".$album."/";
$dir = $dir.$naam;
move_uploaded_file($_FILES['bestand']['tmp_name'],$dir);
$chmod = "./fotos/".$album."/".$naam;
chmod($chmod, 0644);
include("connect.php");
$bestand = mysql_escape_string($_FILES['bestand']['name']);
$insert = "insert into foto (naam,album,bestand) values ('$naam','$album','$bestand')";
$query = mysql_query($insert);
echo "De foto werd met succes geupload!";
}
}
else
{
echo "dit is geen afbeelding!";
}
}
else
{
?>
<form action="toevoegen.php" method="post" enctype="multipart/form-data">
<table cellspacing="0" cellpadding="0" border="0" width="100%">
<tr>
<td>Kies een foto om toe te voegen:</td>
</tr>
<tr>
<td>
<table>
<tr>
<td width="100">bestand:</td>
<td>
<input type="file" name="bestand" />
<input type="submit" name="fototoev" value="Foto toevoegen" />
</td>
<tr>
<td width="100">album:</td><td><input type="radio" checked name="album" value="1" /><select name="salbum"><?
$select = "select album from foto group by album";
$query = mysql_query($select);
while($list = mysql_fetch_object($query))
{
echo "<option value=\"".$list->album."\">".$list->album."</option>";
}
?>
</select>
</td>
</tr>
<tr>
<td /><td><input type="radio" name="album" value="0" /><input type="text" name="nalbum" /></td>
</tr>
</table>
</td>
</tr>
</table>
</form>
<?
}
?>
</td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing="0" cellpadding="0" border="0" width="100%" height="100%"> <tr> <td align="center" height="20" width="75%" style="border-bottom: 1px solid #1ab4e1">foto toevoegen</td> <td align="center" width="15%" style="border-left: 1px solid #1ab4e1; border-bottom: 1px solid #1ab4e1"> <? $maand = array("niet", "januari", "februari", "maart", "april", "mei", "juni", "juli", "augustus", "september", "oktober", "november", "december"); echo $j." ".$maand[$n]." ".$Y; ?> </td> </tr> <tr> <td colspan="2"> <table cellspacing="0" cellpadding="0" border="0" width="100%"> <tr> <td width="10"></td> <td valign="top"> <? if(isset($_POST['fototoev'])) { $naam = basename($_FILES['bestand']['name']); { if($_FILES['bestand']['name'] == '' || $_FILES['bestand']['size'] >= '1000000') { if($_FILES['bestand']['name'] == '') { echo "U hebt geen bestand geselecteerd!"; } else { echo "Het bestand is te groot!"; } } else { if($_POST['album'] == 1) { $album = $_POST['salbum']; } else { $album = $_POST['nalbum']; $ndir = "fotos/".$album; } $dir = "fotos/".$album."/"; $dir = $dir.$naam; $chmod = "./fotos/".$album."/".$naam; include("connect.php"); $insert = "insert into foto (naam,album,bestand) values ('$naam','$album','$bestand')"; echo "De foto werd met succes geupload!"; } } else { echo "dit is geen afbeelding!"; } } else { ?> <form action="toevoegen.php" method="post" enctype="multipart/form-data"> <table cellspacing="0" cellpadding="0" border="0" width="100%"> <tr> <td>Kies een foto om toe te voegen:</td> </tr> <tr> <td> <table> <tr> <td width="100">bestand:</td> <td> <input type="file" name="bestand" /> <input type="submit" name="fototoev" value="Foto toevoegen" /> </td> <tr> <td width="100">album:</td><td><input type="radio" checked name="album" value="1" /><select name="salbum"><? $select = "select album from foto group by album"; { echo "<option value=\"".$list->album."\">".$list->album."</option>"; } ?> </select> </td> </tr> <tr> <td /><td><input type="radio" name="album" value="0" /><input type="text" name="nalbum" /></td> </tr> </table> </td> </tr> </table> </form> <? } ?> </td> </tr> </table> </td> </tr> </table>
Download code (.txt)
|
|
Stemmen |
Niet ingelogd. |
|