Forum Moderators: coopster
I'm trying to determine the most recent post from 5 mysql tables. I'm doing this by calling the last post from the five tables and making variables from them (based on the date).
Then, these variables are put into an array with a key => val thing to name the table they came from:
$lastarray = array (
$last_table1 => "forum_table1_post",
$last_table2 => "forum_table2_post",
$last_table3 => "forum_table3_post",
$last_table4 => "forum_table4_post",
$last_table5 => "forum_table5_post"
);
Then the plan was this:
1. ksort that array by the date ($last_tablex)
2. get the most recent date from the array
3. have two variables that represent the most recent date and the table it's from.
Does that make sense? How do I get that information?
OR
Is there a better way to find the most recent post of the 5 mysql tables?
Thanks in advance.
- fresh
How about a new table that keeps track of posts to all tables! Then you can select all this information in one simple statement. Call this new table, last_post.
table
datetime
(other fields if you want. Like: title, author, desc)
This keeps your selects down to just one, Instead of five! If you are displaying this information everytime a person visits your site. The one select statement would be better.