latest entry in multiple tables

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
marthaller
Forum Newbie
Posts: 3
Joined: Wed Mar 31, 2010 6:34 am

latest entry in multiple tables

Post by marthaller »

I've just designed a website that hosts a tri-weekly comic and blog posts by two people. On the homepage I have the latest comic, and latest post by each person. what I want to do is put the most recent one of each in order of date on the page. it's easy with the blog, as the layout is the same in each, but integrating it with the comic I"m having trouble with. can anybody help. thanks.
roders
Forum Commoner
Posts: 68
Joined: Tue Oct 20, 2009 9:29 am

Re: latest entry in multiple tables

Post by roders »

If you're using a query, then normal a simple "order by [fieldnameholdingdate]" should suffice to sort each in date order.
marthaller
Forum Newbie
Posts: 3
Joined: Wed Mar 31, 2010 6:34 am

Re: latest entry in multiple tables

Post by marthaller »

thanks or the quick reply. I have no trouble getting the entry, but when I have these three entries, there are two different formats dopending on if it's a comic of blog entry. that's what I'm trying to figure out. thanks
User avatar
Weiry
Forum Contributor
Posts: 323
Joined: Wed Sep 09, 2009 5:55 am
Location: Australia

Re: latest entry in multiple tables

Post by Weiry »

marthaller wrote:thanks or the quick reply. I have no trouble getting the entry, but when I have these three entries, there are two different formats dopending on if it's a comic of blog entry. that's what I'm trying to figure out. thanks
What roders posted has nothing to do whether you have trouble getting the entry... its an SQL update to sort by the most recent entry by date.
Although it should read:

Code: Select all

SELECT * FROM `yourTable` ORDER BY `dateTime` DESC
Where DESC puts the most recent first.

However.. you have not indicated any sort of table structure for your comics/blog nor have you provided any code for us so that we have a bone to play with, so its slightly difficult to give you a 100% correct solution.
Post Reply