View Single Post
Old 02-07-2007, 01:17 PM   #15 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,505
sde is on a distinguished road
keep in mind, i'm not testing this code.. just use it for a logic reference.. most of it should work though.

Code:
$sql = "CREATE TABLE images (
  `imageid` int(10) unsigned NOT NULL auto_increment,
  `filename` varchar(32) NOT NULL default '',
  `caption` varchar(64) NOT NULL default '',
  PRIMARY KEY  (`imageid`),
  UNIQUE KEY `filename` (`filename`)
  ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;";
this table will automatically increment the ID so you don't have to insert the id when you add an image. it's not necessary to have that field but i prefer to handle individual elements of a table with an integer.

the filename is unique, so you won't be able to have duplicate entries for a filename. since all your files are in the same upload directory, that's probably best.

keep in mind, there's a lot of ways to do what you're doing .. i'm just posting one way to help you get something up so you can tweak it to your needs.
__________________
Mike
sde is offline   Reply With Quote