Image Gallery Administration

"; while($r = mysql_fetch_array($select)){ extract($r); ?> <?=$title?> Edit Picture Delete Picture "; ?>





"; echo "Data Added."; } else { "Couldn't move"; } }//is an image else { echo "This isn't an image
"; echo $file['type']; }//isn't image }//end isset file else { echo "File isn't set"; } break;//end add case "edit": $select = mysql_query("SELECT * FROM gallery WHERE id = ".$_GET['id']) or die(mysql_error()); $row = mysql_fetch_row($select); $id = $row[0]; $title = $row[1]; $description = $row[2]; $image = $row[3]; $basename = $row[4]; ?> <?=$title?>





Leave Alone If You Want The Same Image:

$value){ $$key = htmlspecialchars($value); } $id = $_GET["id"]; $select = mysql_query("SELECT basename FROM gallery WHERE id = ".$id) or die(mysql_error()); $row = mysql_fetch_row($select); $basename0 = $row[0]; if(mysql_query("UPDATE gallery SET title = '".$title."', description = '".$description."'") or die(mysql_error())){ echo "Updated.
"; if($_FILES["image"]){ $file = $_FILES["image"]; $basename = date("d-m-Y-G-j-s-").basename($file['name']); if($file['type'] == 'image/gif' || $file['type'] == "image/jpeg" || $file['type'] == "image/pjpeg" || $file['type'] == 'image/png'){ if(unlink($basename0) && move_uploaded_file($file['tmp_name'], $basename)){ echo "Moved File
"; echo "
"; if(mysql_query("UPDATE gallery SET basename = '".$basename."', image = 'http://www.shadow-fox.net/examples/imagegallery/$basename'") or die(mysql_error())){ echo "Image Location updated."; } else { echo "Image Location could not be updated."; } } else { "Couldn't move"; } }//is an image }//if file is there }//updated else { echo "Could not update."; }//didn't update break; case "delete": $select = mysql_query("SELECT * FROM gallery WHERE id = ".$_GET['id']) or die(mysql_error()); $row = mysql_fetch_row($select); $unlink = unlink($row[4]); if($unlink && mysql_query("DELETE FROM gallery WHERE id = ".$_GET['id']) or die(mysql_error())){ echo "Image Deleted."; } else { echo "Image Could Not Be Deleted."; } break; }//end switch } else { ?>

Log in