cosmicsea
11-08-2010, 11:17 PM
Hi, For my tag cloud I show my last 5 searches and how many results were shown for that search and the query time. My question is how can I get my query time to show "1 second ago, 1 minute 32 seconds ago, or 1 hour ago etc"? Instead of being displayed like this.
2010-11-08 17:10:56
I know this is possible. I am just not sure if I do it with mysql or php or both.
Can anyone help with this?
Here is my code that I am working on.
<?php
$class = "evrow";
echo "
<table width='60%' align='center'>
<td class='tblhead'>Query</td>
<td class='tblhead'>Results</td>
<td class='tblhead'>Queried at:</td>
</tr>
";
$num = '1';
$result=mysql_query("select query, date_format(time, '%Y-%m-%d %H:%i:%s'), results from ".$mysql_table_prefix."query_log order by time desc");
if ($debug > '0') echo mysql_error();
while (($row=mysql_fetch_row($result)) && ($num <= '5')) {
if ($class =="evrow")
$word = $row[0];
$time = $row[1];
$results = $row[2];
echo "<tr class='$class'>
<td><a href='../search.php?query=$word&search=1' target='rel' title='View search results in new window'>".($word)."</a></td>
<td> ".$results."</td>
<td> ".$time."</td>
</tr>
";
$num++;
}
2010-11-08 17:10:56
I know this is possible. I am just not sure if I do it with mysql or php or both.
Can anyone help with this?
Here is my code that I am working on.
<?php
$class = "evrow";
echo "
<table width='60%' align='center'>
<td class='tblhead'>Query</td>
<td class='tblhead'>Results</td>
<td class='tblhead'>Queried at:</td>
</tr>
";
$num = '1';
$result=mysql_query("select query, date_format(time, '%Y-%m-%d %H:%i:%s'), results from ".$mysql_table_prefix."query_log order by time desc");
if ($debug > '0') echo mysql_error();
while (($row=mysql_fetch_row($result)) && ($num <= '5')) {
if ($class =="evrow")
$word = $row[0];
$time = $row[1];
$results = $row[2];
echo "<tr class='$class'>
<td><a href='../search.php?query=$word&search=1' target='rel' title='View search results in new window'>".($word)."</a></td>
<td> ".$results."</td>
<td> ".$time."</td>
</tr>
";
$num++;
}