Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#25 2007-04-20 19:49:13

variaas
Plugin Author
From: Chicago
Registered: 2005-01-16
Posts: 402
Website

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

#27 2007-04-20 21:15:09

variaas
Plugin Author
From: Chicago
Registered: 2005-01-16
Posts: 402
Website

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

#29 2007-04-20 21:53:43

variaas
Plugin Author
From: Chicago
Registered: 2005-01-16
Posts: 402
Website

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

Board footer

Powered by FluxBB