simple array? question

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
penciLneck
Forum Newbie
Posts: 15
Joined: Fri Nov 28, 2003 10:13 am
Location: Daarsit

simple array? question

Post by penciLneck »

Ok this should be a simple question, but maybe my explanation will be complex. :)

I'm displaying listings of events on a page vertically, one after the other, rather like a blog or something. the data for each event comes from 2 tables _events and _instances ( because there can be more than one instance of event, eg at several locations ). I thought I could just use a simple join select SQL query to an array on the page and then echo the results into the right places in my layout, but how do I ensure that the instances of each event (if there are any) are automatically put in the right place? Does that make sense? This is what I'd like to happen:

my page

event1
description
image
instance 1
instance 2
----------------
event2
description
image
instance 1
----------------


so each event would have the right number of instances displayed after it on the page, dependant on how many instances were in the database under the same key as the event. The join to get the data seems easy,

Code: Select all

SELECT event.title,event.desc, FROM events,instances WHERE event.id=instances.eventid
but how do I then display the instances correctly after each separate event in that vertical listing fashion? Separate arrays? different code?

hope I've explained myself coherantly.

any help would be much appreciated.

pN.
Post Reply