Welcome to Dream.In.Code
Getting PHP Help is Easy!

Join 136,466 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 1,555 people online right now. Registration is fast and FREE... Join Now!




Images gallery.... Advices on categories and mysql. Want to build prof

 
Reply to this topicStart new topic

Images gallery.... Advices on categories and mysql. Want to build prof, Designing a proffesional

Dancia
3 Jul, 2008 - 01:01 PM
Post #1

D.I.C Head
**

Joined: 15 Jun, 2008
Posts: 57



Thanked: 1 times
My Contributions
For this time I want to make a images gallery with all extra stuff. But I saw big sites like deviantart, imageshack or photopucket use weird (unknown for me) navigation. They navigate all stuff by folders i guess biggrin.gif (/art/.../2008/../My_peace_of_art_or_smth

So I thoughs maybe they aren't using mysql and indexing all stuff in different way...

Also I would like to know if i write everyting into mysql, will it become slow for example after 100k images in one table. (100k ID's I guess is a lot!)?

How do they control such a lot stuff?

Would be great If someone could explain all those /.../.../my_art

Currently im navigating my site with variables. (biggrin.gif ?action=...&do...). I saw that big files don't do such stuff. Why?

I really want to build a good web site. Working on this project more than one year.

Ok and finally about categories. By creatings a mysql table for all categories
how to setup sub categories. (I know i could make more tables, bt every gallery category will have not thesame number of subs).

Thanks...
User is offlineProfile CardPM
+Quote Post

Mike007
RE: Images Gallery.... Advices On Categories And Mysql. Want To Build Prof
3 Jul, 2008 - 03:05 PM
Post #2

D.I.C Head
Group Icon

Joined: 30 Aug, 2007
Posts: 205


Dream Kudos: 75
My Contributions
Ok I just started a topic about some of the stuff you are talking about, here:
http://www.dreamincode.net/forums/showtopic56318.htm

Now, you don't save images to the database, that would be stupidly expensive in terms of memory and resources. You don't really need it in the database, you only need information about it and where to find it. So your database would look something like this

CODE

id    address    date                size       description
---   ---------               -----               ----       -------------
1      mydog.jpg    2008-07-01      125           A picture of my dog on canada day.
.
.
.


Something like that, you can even use the address/name field as your primary key instead of having an id key. The idea of a database is to enable you to index files so you can pull data out fast. An image itself does not hold data you can look for, I'm talking about the pixels or the vectors. Unless you are making a special software that can compare pictures, like a face recognition program then you have no need to use a database.

Now the pictures you would store in a folder (just like all the uploading sites do), change the name to make it unique tho by appending the date to the name or something like that, and register it in your database.

About the categories, you don't have a table for each category, that would be a waste. You create a table that contains category names a category id, then you use the category id as the primary key and a foreign key to your pictures table. Try drawing a ERD and think about the relationships and events that will happend in your system. But, you can upload each picture to a different place on your harddrive and then point to it in your database.

And one last thing to help you out, there is a tutorial here about how to upload a picture in PHP, you should check it out.

edit: sorry the table is all messed up, I tried to fix it, didn't go well...

This post has been edited by Mike007: 3 Jul, 2008 - 03:08 PM
User is offlineProfile CardPM
+Quote Post

mocker
RE: Images Gallery.... Advices On Categories And Mysql. Want To Build Prof
3 Jul, 2008 - 03:11 PM
Post #3

D.I.C Regular
Group Icon

Joined: 14 Oct, 2007
Posts: 258



Thanked: 15 times
Dream Kudos: 25
My Contributions
The paths you see in the url (/art/.../2008/../My_peace_of_art_or_smth and so on) do not mean deviant art stores has a folder named art/../2008.. and so on. You can rewrite the urls, so when someone types in the above, the server might actually reads it as gallery.php?category=art&year=2008.. which would load directly into the php script as variables you can use to determine what image to show.

If you are using apache, lookup mod_rewrite for how to use urls like that.
User is offlineProfile CardPM
+Quote Post

Dancia
RE: Images Gallery.... Advices On Categories And Mysql. Want To Build Prof
4 Jul, 2008 - 09:20 AM
Post #4

D.I.C Head
**

Joined: 15 Jun, 2008
Posts: 57



Thanked: 1 times
My Contributions
Ok could i do in this way.
Images:
CODE

id............file_name..........description.......category
1..............potatoes.jpg.......tasty stuff............2
2...............oranges.jpg.......delicious...............3
3................potato_human.jpg........Lovely flower!........4


And categories:
CODE

id............belongs_to_id........category_name
1.....................1.......................nature
2.....................1.......................vegetables
3.....................1.......................fruits
4.....................2.......................misc


And so If I need picture id 2 i know that it belongs to catewgory 3 which is fruits and fruits is in nature. So I get nature/fruits/oranges.jpg

If I need picture id 3 I know it's in misc which is in vegetables and vegetables are in nature. So I get nature/vegetables/misc/potato_human.jpg

If I need all nature, not single picture, I look at categories and take id 1 and display:
1.....................1.......................nature (actually can't, coz its empty, only subs)
2.....................1.......................vegetables (nature/vegetables/)
4.....................2.......................misc (nature/vegetables/misc)
3.....................1.......................fruits (nature/fruits/)
And display images where categoriesw are 2, 4 or 3
What do you think of it?

I think Its a bit stupid, coz I have no Idea how to EFFECTIVELY make it in php. I also think that it's too long proccess to take single image. But thats all I can biggrin.gif

Waiting for posts.

This post has been edited by Dancia: 4 Jul, 2008 - 09:22 AM
User is offlineProfile CardPM
+Quote Post

Mike007
RE: Images Gallery.... Advices On Categories And Mysql. Want To Build Prof
8 Jul, 2008 - 08:01 PM
Post #5

D.I.C Head
Group Icon

Joined: 30 Aug, 2007
Posts: 205


Dream Kudos: 75
My Contributions
Ok, if you only have two types of categories, general one and more specific once, and every sub-category belongs to only one general category then you can use a table to hold the categories and they will be linked to the sub-categories table which in turn will be linked to your images table. Now if you have many to many relationships there then you will have to think about it a little bit more.

Also, I have to say this reminds me of a tree structure so be sure to check that data structure out and how to save it into a database, it might just give you the answer.

User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/2/08 05:02PM

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month