Go Back   SitePoint Forums > Forum Index > Program Your Site > PHP
Newsletter FAQ Members List Calendar Mark Forums Read

New to SitePoint Forums? Register here for free!

SitePoint Sponsor
 
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Old Dec 5, 2006, 14:59   #1
Iceman90
SitePoint Addict
 
Iceman90's Avatar
 
Join Date: Mar 2006
Location: Calgary, Alberta, Canada
Posts: 368
PHP and mySQL - comparing data from two tables

Hello everyone. I am having a problem that I was hoping someone here would be able to assist me with.

I am using PHP and mySQL to create a site that reviews DVDs and Music. What I'd love to do is to create a list of release dates. In this list, I'd like it to look something like this

December 5, 2006
DVD
DVD
Album
Album

November 29, 2006
DVD
DVD
Album
Album
Album

November 27, 2006
Album



I have 2 tables in my database. One to hold the information about my DVDs, and one to hold my information about my albums.

What I can't seem to get, is for the data from both tables to display in this way.

It's easy enough to do with the data from one table, as you just query the data, and display it, sorted by date.

However, I guess what I am asking, is how do I compare the dates between the two tables, and then display the information (be it a DVD or an album) for all the selected date?

At first I thought I could use a mySQL JOIN command, but then I don't get all the dates that don't have both a DVD and an album released, so I am assuming PHP.

I am assuming I'd have to read both sets of dates out of the database, and into an array. Then, using a loop, loop through the dates and find any DVDs or albums that match, and display them. I am just not sure how I'd go about this, or if there is a better method.

Any thoughts or advice?
Iceman90 is offline   Reply With Quote
 

Bookmarks

« Previous Thread | Next Thread »

Thread Tools
Display Modes

 
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
Sponsored Links
 
Forum Jump


All times are GMT -7. The time now is 02:42.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Copyright 1998-2009, SitePoint Pty Ltd. All Rights Reserved