Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > How would you implement this? (PHP, MySQL, apache)

How would you implement this? (PHP, MySQL, apache)
Thread Tools
Fresh-Faced Recruit
Join Date: Apr 2002
Location: Boston, MA, USA
Status: Offline
Reply With Quote
May 5, 2002, 11:05 AM
 
This will be detailed one...

I recently rewrote my webpage (locally hosted!) in PHP with a MySQL backend. I am completely new to all of this, so I assume that the solutions I implemented are non-optimal. Basically, how would you structure this?

Webpage info:
Webpage is a photo gallery site. Each photo has a base name (image path and thumbnail path are derived from the name), a title and associated info (location, date, etc). The pictures are arranged in categories.

Each category has a name, title, etc. Pictures can appear in more than one category, or in no categories (i.e. not appear at all).

What I'd like to ask is, how would you set up your MySQL tables?

-Gabe

edit: I supose I should tell you how I did it so you can tell me how wrong I was.

Table:
images - each row holds an image name, date, etc.
categories - each row holds category name, title, etc.
Each category has a table with the same name as the category. These tables simply hold a list of the names of the images in that category.

Thanks for your help.

[ 05-05-2002: Message edited by: GRedner ]
     
Grizzled Veteran
Join Date: Sep 2000
Location: Springfield, MA
Status: Offline
Reply With Quote
May 5, 2002, 12:45 PM
 
Originally posted by GRedner:
<STRONG>What I'd like to ask is, how would you set up your MySQL tables?
...
Table:
images - each row holds an image name, date, etc.
categories - each row holds category name, title, etc.
Each category has a table with the same name as the category. These tables simply hold a list of the names of the images in that category.</STRONG>
The way I see it you only need 3 tables. The images and categories tables that you already have, and then the third is a table that stores the relations between them.

This table would have 2 fields: a foreign key pointing to an image, and a foreign key pointing to a category.

This way, you have an entry in that 3rd table for each category that an image is in, so if image "mycat" is in categories "foo" and "bar", then you would have two entries for "mycat", one that links it to "foo", and one that links it to "bar".

Make sense to you? That is how I would do it.
We hope your rules and wisdom choke you / Now we are one in everlasting peace
-- Radiohead, Exit Music (for a film)
     
Dedicated MacNNer
Join Date: Oct 2000
Location: Washington, DC
Status: Offline
Reply With Quote
May 5, 2002, 06:09 PM
 
If you really want to write it yourself, you can ignore this.

But I would suggest checking out Gallery
http://www.sourceforge.net/projects/gallery

It's a really well done photo album site, and its easy to set up and get going. Save yourself the effort of having to reinvent the wheel, and since its open source, you can diddle around with the source to implement features you'd like to put in.

-tim
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 02:54 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2