Skip to content

Instantly share code, notes, and snippets.

@lizheming
Created Oct 2, 2010
Embed
What would you like to do?
<?php
define(P2_PATH,'http://pagecookery.net/'); //输入你的PageCookery地址,不要忘记最后的"/"哦!
include("config.php");
mysql_connect(DATABASE_HOST, DATABASE_USER, DATABASE_PSSWORD) or
die("Could not connect: " . mysql_error());
mysql_select_db(DATABASE_DB_NAME);
mysql_query("SET NAMES UTF8");
$sqlx="select * from entry where userid='1' order by time desc limit 1";
$rsx=mysql_query($sqlx);
if (mysql_num_rows($rsx)!==0):
while ($datax=mysql_fetch_assoc($rsx)):
$contentx=$datax["content"];
$timex=$datax["time"];
$idx=$datax["id"];
endwhile;
endif;
echo '<div class="content">' . $contentx . '</div><p class="data"><a href="'. P2_PATH . '?act=view&id=' . $idx . '" target="_blank">';
$pasttime=time()-$timex;
if ($pasttime<60)
{
echo 'about&nbsp;'.$pasttime.'&nbsp;seconds ago';
}else if ($pasttime>60 && $pasttime<3600)
{
echo 'about&nbsp;'.floor($pasttime/60).'&nbsp;minutes ago';
}else if ($pasttime>3600 && $pasttime<86400)
{
echo 'about&nbsp;'.floor($pasttime/3600).'&nbsp;hours ago';
}
else{
print_r(date('Y-n-j H:i:s', $timex));
}
echo '</a></p>';
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment