Jump to content

Image database table


gsencan

Recommended Posts

I am showing 20 pics per page in 9 different categories.

So i wanted to use a database for images since it got out of control...

 

I want to create a table for images.The basic thing i want is:

show image name and image from newest to oldest

 

should something like this work?

ID / NAME(image name) / IMAGE PATH / IMAGE URL

 

Or should i store images directly to database ? Any table structure suggestions?

i dont know much about sql. 

 

Link to comment
Share on other sites

Hi,

I'm far from being even a novice at php but I thought I'd add my 2 pennies worth as I recently had a similar issue.

 

I've got a similar system, whereby I have images for many different galleries all with different gallery names. My table has an ID, Gallery name and image path.

 

That way for each different gallery you can put a WHERE clause in the query and only images designated for that gallery are displayed.

 

Then get the images to save in a given directory.

 

To sort the images by date added I guess having a date_added row would be an idea.

 

Again, don't take my word for it as there are far more qualified people on here.

Link to comment
Share on other sites

First off, a database isn't really made to be a file system, so I wouldn't store the images in the database. Instead you should store what you would need to access the file. So, your database may be different depending on how you plan on storing the images.

 

usually I have a root image directory, in there other directories, for example:

sub1

sub2

sub3

 

This will spit the load on each directory. If you do that you would need this (example):

directory, image, extension

 

- directory will contain sub1, sub2 or sub3.

- image will be the image name "My_Cool_Image"

- extension will be the extension of the file: jpg, gif, png, etc.

 

now if you store the images all over the place, such as different servers you would probably do something like this:

server, directory, image, extension

 

- server would be the server saved the image on such as "images.srv1"

- directory would be the location on the server "/downloads/user"

- image would be the image name

- extension would be the extension

 

When you build this it would look like so:

http://images.srv1.site.com/downloads/user/My_Cool_Image.jpg

or

http://images.srv5.site.com/usrData/user/1234/profile_pic.jpg

 

Their are lots of ways to store images in the database, and all ways are different, it just depends on what your needs are.

Link to comment
Share on other sites

My images are in 1 folder and image folder has sub folders like category 1 category 2 .....etc.

So i guess it will be easy to show most recent 20 images for any category.

 

Also can i have 1 table with all images and make a column for category name so i can say something like get most recent 20 images by date from category 1 ? Or make tables for each category for speed ? Atm i have about 500 pics with links to 500 pages

Link to comment
Share on other sites

Ok 1 last question about structure

 

it will be like this:

CATEGORY / IMAGENAME / IMAGEPATH / IMAGEURL / DATE(added)

I will only show image name and image by date on site so as i know so far  :

 

id INT NOT NULL AUTO_INCREMENT,

category VARCHAR(20) NOT NULL,

imagename VARCHAR(30) NOT NULL,

imagepath VARCHAR(60) NOT NULL,

imageurl VARCHAR(60) NOT NULL,

date INT  NOT NULL,                      ==> like : 20110914124005

PRIMARY KEY(id)

 

is it ok?  :confused:

Link to comment
Share on other sites

I see...  so :

id INT NOT NULL AUTO_INCREMENT,

category VARCHAR(20) NOT NULL,

imagename VARCHAR(30) NOT NULL,

date datetime NOT NULL,                     

PRIMARY KEY(id)

 

i was thinking something like adding time manually in 20110814100102 format (because every date-time has a unique number)  but its ridiculous i guess.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.