I am developing my own Wordpress Theme and I need to get data from the row with the latest date stamp.
the column is post_date and rows appears as
2007-07-10 10:54:26
2007-07-10 10:49:11
2007-07-10 10:50:33
2007-07-10 10:54:47
2007-07-04 09:56:09
2007-07-04 09:56:19
2007-07-04 13:56:19
here's were I am going...
# connect to db
$db = mysql_connect("localhost", "root", "root");
mysql_select_db("whiteboarddiaries");
# get all posts
$post_query = 'SELECT * FROM wp_posts WHERE post_type="post"';
$post_results = mysql_query($post_query);
then i want to cycle through each row
while($post_row = mysql_fetch_assoc($post_results))
{
}
and write something like...
while($post_row = mysql_fetch_assoc($post_results))
{
# get the row with the latest date_stamp ($post_row['post_date'])
{
#$post_row should now equal the latest row (what i want)
}
}
is there a function to compare time? how should i approach this?