|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Properties for image gallery
On my personal site I am creating an image gallery script. Here is the table I want to create ..except for the row where the image will be uploaded. Could someone help me out with that? Image won't be bigger than 1280x1024.
Code:
CREATE TABLE gallery ( id INT (1) not null AUTO_INCREMENT, title VARCHAR (50), date DATE -----image properties here---- PRIMARY KEY (id) ); Thanks |
|
#2
|
|||
|
|||
|
Re: Properties for image gallery
Code:
CREATE TABLE gallery ( id INT (1) not null AUTO_INCREMENT, title VARCHAR (50), date DATE -----image properties here---- PRIMARY KEY (id) ); 1. Your id field should probably be larger. 2. the field you want to add could be something like - filename varchar (255) All you need is the name... you don't want to to hardcode a path into your field name... alternatively you can add a path field as well. path varchar (255) For example, a record in this database would have the following in filename: testphoto.jpg In path you might have: /album/photos/album1/
__________________
__________________________________________________ _ Wil Moore III, MCP | Integrations Specialist | Senior Consultant Are You Listed...? | DigitallySmooth Inc. |
|
#3
|
|||
|
|||
|
Code:
CREATE TABLE gallery ( id INT (11) not null AUTO_INCREMENT, title VARCHAR (50), date DATE, img VARCHAR (255), path VARCHAR (40), PRIMARY KEY (id) ); Like that? |
|
#4
|
|||
|
|||
|
Try this:
Code:
CREATE TABLE gallery ( id INT (11) not null AUTO_INCREMENT, title VARCHAR (50), stamp timestamp, added timestamp, img VARCHAR (255), path VARCHAR (255), PRIMARY KEY (id) ); Since you are using mysql you may as well utilize the timestamp field type. The first stamp will be filled with the current time when you first insert the row (don't insert to this field in your insert statement... it will autofill). This setup has the added benefit of having your stamp field get updated with the current time that you modified the record (if you do an update on the field stamp will be updated automatically since it is the first timestamp in the table). The second timestamp (added) will always have the original date/time. |
|
#5
|
|||
|
|||
|
You also might want to create an index on img (for searching), and you should probably do a unique key on path+img (for no dupes)
|
|
#6
|
|||
|
|||
|
Alright, sweet. Learned a couple new things there. THanks!
|
|
#7
|
|||
|
|||
|
Glad to help as always...
![]() |
![]() |
| Viewing: Dev Articles Community Forums > Databases > General SQL Development > Properties for image gallery |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|