Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

The Database Forum


You are currently viewing our The Database Forum as a guest. Please register to participate.
Login



Reply
Old 12-20-2007, 07:27 PM News with images
lizciz's Avatar
Webmaster Talker

Posts: 744
Name: Mattias Nordahl
Location: Sweden
Trades: 0
Hi!

This is my first time in the database forum
On my website there will be a list of news of what has happened recently. News will be stored in a database (using PHP/MySQL) and only the most recent ones will be shown. So far piece a cake.

Now, heres the problem. Every news will aslo be able to hold a number of images (0-5). Images will be stored in a database table of their own. How would I best store this in the database, since I won't know how many images each news got? I should probably store the images id's with each news, but I won't know how many there are.

And just to clarify, the problem isn't storing the images in my database, but how to link the news to their associated images.

Thanks
lizciz
lizciz is online now
Reply With Quote
View Public Profile Visit lizciz's homepage!
 
 
Register now for full access!
Old 12-21-2007, 04:03 AM Re: News with images
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
I use a seperate table for images and store the ID of the item and the path to the image in each row.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 12-21-2007, 08:05 AM Re: News with images
lizciz's Avatar
Webmaster Talker

Posts: 744
Name: Mattias Nordahl
Location: Sweden
Trades: 0
I do too. I believe you didn't read my post very carefully. The problem I'm having is not how to store images in my database, but how to link the images to the news they belong to.

Edit:
Hmm, now that I read my own post, where I wrote "link the images to the news" instead of "link the news to their associated images" I realised I can simply add an attibute 'newsID' to each image that tells which news this image belong to

Last edited by lizciz; 12-21-2007 at 08:13 AM.. Reason: Realisation
lizciz is online now
Reply With Quote
View Public Profile Visit lizciz's homepage!
 
Old 12-21-2007, 08:30 AM Re: News with images
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Yep.

and I've just noticed my post should have read;
Quote:
store the ID of the newsitem and ...
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 12-23-2007, 11:59 PM Re: News with images
Novice Talker

Posts: 13
Trades: 0
each row for each image. (many rows for one news )
skoogo is offline
Reply With Quote
View Public Profile
 
Old 12-29-2007, 05:51 AM Re: News with images
Skilled Talker

Posts: 75
Name: Nick Cousins
Location: Northern Ireland
Trades: 0
Hmmm I would do it like this (but I could be VERY wrong! hehe)

[newsitems table]
uid
title
description
etc..

[images table]
uid
caption
imagefile
etc...

[linkup table]
uid
newsid
imageid

Each row in the linkup table has a newsid (corresponding to a uid in the news items table) and an imageid (corresponding to an uid in the images table).

That way you can have as many images linked to as many news items as you wish.

You can also re-use images in different news items simply by creating more links.
HandCoder is offline
Reply With Quote
View Public Profile Visit HandCoder's homepage!
 
Reply     « Reply to News with images
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting 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 Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.34550 seconds with 12 queries