Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Re: last updated on ...
Not sure where the performance hit may lay, but i like to use SQL. This query will pull the latest excerpt and the date in the format your requested.
<code>
$query = “select Excerpt, date_format(Posted, ‘%e %b %Y’) as Posted from textpattern order by Posted DESC limit 1”;
$result = mysql_query($query);
$row = mysql_fetch_array($result, MYSQL_ASSOC);
//Output the results
echo “Last Modified:{$row[‘Excerpt’]}”;
</code>
Offline
#26 2007-04-20 20:44:28
- systrum
- Member

- Registered: 2004-08-28
- Posts: 44
Re: last updated on ...
with this it outputs
30 Jan 2007
this is with <code>echo “{$row[‘Posted’]}”;</code>
it outputs nothing with <code>echo “{$row[‘Excerpt’]}”;</code>
strange that i get that date
Offline
Re: last updated on ...
<code>
$query = “select date_format(Posted, “%e %b %Y”) as Posted_format, Excerpt from textpattern order by Posted DESC limit 1”;
$result = mysql_query($query);
$row = mysql_fetch_array($result, MYSQL_ASSOC);
//Output the results
echo “Last Modified:{$row[‘Posted_format]}”;
echo “Excerpt:{$row[‘Excerpt’]}”;
</code>
Note that I changed the name of the variable holding the date value in SQL. So to reference it in PHP you’ll have to use $row[‘Posted_format’]
Offline
#28 2007-04-20 21:26:08
- systrum
- Member

- Registered: 2004-08-28
- Posts: 44
Re: last updated on ...
damn! now it gives me
Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/.cambyses/systrum/systrum.net/lastmod.php on line 10
Offline
Re: last updated on ...
Silly me with the double quotes. Fixed:
<code>
$query = “select date_format(Posted, ‘%e %b %Y’) as Posted_format, Excerpt from textpattern order by Posted DESC limit 1”;
$result = mysql_query($query);
$row = mysql_fetch_array($result, MYSQL_ASSOC);
//Output the results
echo “Last Modified:{$row[‘Posted_format]}”;
echo “Excerpt:{$row[‘Excerpt’]}”;
</code>
Offline
#30 2007-04-20 22:10:29
- systrum
- Member

- Registered: 2004-08-28
- Posts: 44
Re: last updated on ...
Perfection!!! variaas, thank you for you patience and generosity! really appreciated
Offline