I have a small issue with PHP/mysql.
I'm trying to get the TITLES of the last 5 posts I made in my blog orderd by the date.
PHP Code:
<?
mysql_connect("server", "user", "pass") or die(mysql_error());
mysql_select_db("database") or die(mysql_error());
$query = mysql_query("SELECT * FROM wp_posts ORDER BY date DESC LIMIT 5");
while($row = mysql_fetch_array($query))
{
$default_title = $row['title'];
$default_date = $row['date'];
$default_title = stripslashes($default_title);
}
echo $default_title;
?>
Now for some odd reason, It shows only one title.
and that title has the ID 5.
So, I was thinking then I changed LIMIT 5 to LIMIT 2 and that one title that was displayed changed to the title from blog entry 2 (which is ID 2).
Database is like.
ID TITLE DATE CONTENT