-- install.php -- (Run this to create your tables)
<?
// config.php would hold the variables to $server, $username, $password, $table, and $database
include("config.php");
// Connect to MySQL Server
@mysql_connect($server, $username, $password) or DIE("Couldn't Connect to MySQL Database");
// Select Database
@mysql_select_db($database) or DIE("Couldn't Select Database");
// Create Tables
// pictures
$query = mysql_query("CREATE TABLE $table (
id int(11) DEFAULT '' NOT NULL auto_increment,
image varchar(25) NOT NULL default '',
PRIMARY KEY (id))");
// The end
echo "Installation Complete";
?>
-- end of install.php --
-- photos.php --
<?
// config.php would hold the variables to $server, $username, $password, $table, and $database
include("config.php");
// Connect to MySQL Server
@mysql_connect($server, $username, $password) or DIE("Couldn't Connect to MySQL Database");
// Select Database
@mysql_select_db($database) or DIE("Couldn't Select Database");
// Gather all your records from the database
$query = mysql_query("SELECT * FROM $table");
// display pictures in tables
print "<table width=200 cellpadding=0 cellspacing=5 border=0>\n";
while ($a_row = mysql_fetch_array($query)) {
print "<tr>\n";
print "<td width=200><a href=full_size.php?image= " . $a_row["image"] . "><img src=images/" . $a_row["image"] . "></a>\n";
print "</td>\n";
print "</tr>\n";
// end your while loop
}
// end your table
print "</table>\n";
?>
-- end of photos.php --
-- full_size.php --
<?
print "<center>\n";
// you can call up the image without the database now because the variable $image is passed in your url
// note it's not calling up the small image because I put images/big/ before the $image.
print "<img src=images/big/" . $image . " width=600 height=600 border=0>\n";
print "<br><br>\n";
print "<a href=photos.php>Back to Photos</a>\n";
print "</center>\n";
?>
-- end of full_size.php --
Now to add photos to the database, the easiest way is for you to upload them into an image directory using an FTP Program.
within that image directory, you'll have another directory called big. this is where you'll put the images
that are bigger, but they have to have the same file name. example
[images directory] (/images)
picture_1.jpg
picture_2.jpg
[big directory] (/images/big)
picture_1.jpg (same name but this image is bigger)
picture_2.jpg (same name but this image is bigger)
Upload your images into these directories, then make a form where you can type in the image name.
-- adminform.php --
<form method="post" action="process.php">
Image Name: <input type="text" name="image" size="20">
<input type="submit" value="submit">
</form>
-- end of adminform.php --
Note that when you type in your image name, don't type in images/picture_1.jpg, just type in (the filename) picture_1.jpg
-- process.php --
<?
// config.php would hold the variables to $server, $username, $password, $table, and $database
include("config.php");
// Connect to MySQL Server
@mysql_connect($server, $username, $password) or DIE("Couldn't Connect to MySQL Database");
// Select Database
@mysql_select_db($database) or DIE("Couldn't Select Database");
// insert image name into database
$query = mysql_query("INSERT INTO $table (image) VALUES ('$image')");
echo "Image inputted successfully. Click <a href=http://www.yourwebsite.com>here</a> to return to your web site\n";
?>
-- end of process.php --
I haven't tested this so there may be a few parse errors here and there, but this should get you well on your way. Post back if you need help
Cgraz