Show latest release of software download

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
hairyjim
Forum Contributor
Posts: 219
Joined: Wed Nov 13, 2002 9:04 am
Location: Warwickshire, UK

Show latest release of software download

Post by hairyjim »

Hi all,

If I have posted this in the wrong forum then my apologies.

I just can't figure the logic or how to do this in my head.

Basically I have a table of product downloads. This table holds all the data for all the product downloads available.

What I wish to do is to display on a page the latest release for each product. So rather than getting a full list of all the releases just get the latest version for each product and diplay them in a list.

So for instance there could be 5 Product A downloads and 3 Product B downloads. I want to select the latest download for both Product A and Product B and list them.

Product A Release 01/07/04
Product B Release 25/06/04

Do I make sense?

Hope someone can give me some sort of inspiration, my mind has turned to mush now.
kettle_drum
DevNet Resident
Posts: 1150
Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England

Post by kettle_drum »

Store the releases in a database and then do an ORDER BY date_released with DISTINCT product name, and then print the results.
hairyjim
Forum Contributor
Posts: 219
Joined: Wed Nov 13, 2002 9:04 am
Location: Warwickshire, UK

Post by hairyjim »

Ahhh fantastic. And here I was thinking of some complex loop.

So how would I build the SQL statement so I can display the title of these records etc.

For instance if I did this:

Code: Select all

$sql = "SELECT DISTINCT product, title, DATE_FORMAT(release_date,'%d/%m/%Y') as formatted_release_date FROM downloads ORDER BY release_date";
It would select the unique Products, titles etc. How do I do the DISTINCT selection but still get accesss to the other fields?
hairyjim
Forum Contributor
Posts: 219
Joined: Wed Nov 13, 2002 9:04 am
Location: Warwickshire, UK

Post by hairyjim »

Can I access the other fields in the DB when I use a 'distinct' query?
Post Reply