Code: Select all
<?php
include("header.php");
$conn = include($_SERVER['DOCUMENT_ROOT']."/webadmin/library/openconndb.php");
print "test";
//START IMAGE DISPLAY
if(isset($_REQUEST['imgid'])){
if(is_int($_REQUEST['imgid'])){
$imgid = mysql_real_escape_string($_REQUEST['imgid']);
$query = "select * from picture_database where id = '$imgid'";
$result = mysql_query($query, $conn);
$imgarray = mysql_fetch_assoc($result);
print "<center>\n";
print "<h2>".$imgarray['name']."</h2>\n";
print "<img src=\uploaded\\".$imgarray['imagelocation']."\">";
print "<br \>\n".$imgarray['description'];
}
}
//END IMAGE DISPLAY
//START THUMBNAIL DISPLAY
if(isset($_REQUEST['catid']){
if($_REQUEST['pageid']){
$pageid = $_REQUEST['pageid'];
}else{
$pageid = 0;
}
if(!is_int($_REQUEST['catid'])){
print "<center>Page error. Please try again.</center>";
}else{
$catid = mysql_real_escape_string($_REQUEST['catid']);
$query = "select * from picture_categories where id='$catid'";
$result = mysql_query($query, $conn);
$catarray = mysql_fetch_array($result);
print "<h2>Album: ".$catarray['name'];
$query = "select * from picture_database where category_id = '$catid'";
$result = mysql_query($query, $conn);
if(mysql_num_rows($result)==0){
print "There are no pictuers in this category."
}else{
$i = 0;
while($pictureData = mysql_fetch_assoc($result);)){
$picture_array[] = $pictureData;
}
while($i<= $count-1){
$countarray[] = $picture_array[$i];
$i++;
}
$row_chunks = array_chunk($countarray, 4);
$page_chunks = array_chunk($row_chunks, 4);
$i=0;
print '<table width=100% border=1 cellspacing=0 cellpadding=10>';
foreach($page_chunks[$pageid] as $rows){
print '<tr>';
$colcount = count($rows);
print '<tr>';
foreach($rows as $columns){
print '<td width=25%><center>';
print '<a href="pictures.php?imgid='.$columns['id'].'">'.'<img src="thumbnails/'.$columns['thumblocation'].'" border=0 />'
print $columns['name']."</a><br />\n";
print $columns['description']."<br />\n";
print date('F j, Y', $columns['date'])."<br />\n";
print '</center></td>';
}
switch($colcount){
case 4:
break;
case 3:
echo "<td width=25%> </td>\n";
break;
case 2:
echo "<td width=25%> </td>\n";
echo "<td width=25%> </td>\n";
break;
case 1:
echo "<td width=25%> </td>\n";
echo "<td width=25%> </td>\n";
echo "<td width=25%> </td>\n";
break;
}
print '</tr>';
}
print '</table>';
$numberOfPages = count($page_chunks);
$i = 0;
print '<b>Pages: </b>';
while($i <= $numberOfPages-1){
print "<a href=\"pictures.php?catid=".$catid."&pageid=".$i."\">".($i+1)."</a>";
$i++;
}
}
}
}
//END PICTURE DISPLAY
//START CATEGORY DISPLAY
if(!isset($_REQUEST['catid']) && !isset([$_REQUEST['imgid'])){
?>
<h1>Choose A Picture Album</h1>
<br>
<?php
if($_REQUEST['pageid']){
$pageid = $_REQUEST['pageid'];
}else{
$pageid = 0;
}
$query = "select * from picture_categories ORDER by id DESC";
$result = mysql_query($query, $conn);
if(mysql_num_rows($result) == 0){
?>
<h2>No Categories have been created.</h2>
<?php
}else{
$count=mysql_num_rows($result);
$i = 0;
while($categoryinfo = mysql_fetch_array($result)){
$category_array[] = $categoryinfo;
}
while($i <= $count-1){
$countarray[]= $category_array[$i];
$i++;
}
$row_chunks = array_chunk($countarray, 4);
$page_chunks = array_chunk($row_chunks, 4);
$i=0;
print '<table width=100% border=1 cellspacing=0 cellpadding=10>';
foreach($page_chunks[$pageid] as $rows){
print '<tr>';
$colcount = count($rows);
foreach($rows as $columns){
print '<td width=25%><center>';
print '<a href="pictures.php?catid='.$columns['id'].'">'.$columns['name']."</a><br />\n";
print $columns['description']."<br />\n";
print date('F j, Y', $columns['date'])."<br />\n";
print $columns['creator']."<br />\n";
print '</center></td>';
}
switch($colcount){
case 4:
break;
case 3:
echo "<td width=25%> </td>\n";
break;
case 2:
echo "<td width=25%> </td>\n";
echo "<td width=25%> </td>\n";
break;
case 1:
echo "<td width=25%> </td>\n";
echo "<td width=25%> </td>\n";
echo "<td width=25%> </td>\n";
break;
}
print '</tr>';
}
print '</table>';
$numberOfPages = count($page_chunks);
$i = 0;
print '<b>Pages: </b>';
while($i <= $numberOfPages-1){
print "<a href=\"pictures.php?pageid=".$i."\">".($i+1)."</a>";
$i++;
}
}
?>
<br><br>
<center>
<a href="addpicturecategory.php">Add a Category</a>
</center>
<?php
}
//END CATEGORY DISPLAY
include("footer.php");
?>