Welcome! Log In Create A New Profile

Advanced

top 20 searches

Posted by Ant 
Ant
top 20 searches
September 28, 2014 06:01AM
Hello!

Is there is some way to embed top 20 most popular searches to the external page?

Thank you.

Anton.
Tec
Re: top 20 searches
September 28, 2014 06:19PM
Open in your editor the script
…/admin/admin.php
and find
			if ($type=='top_searches') {
				$class = "grey";
				print "<br/><div align=\"center\"><table cellspacing =\"0\" cellpadding=\"0\" class=\"darkgrey\"><tr><td><table cellpadding=\"3\" cellspacing = \"1\"><tr  class=\"grey\"><td><b>Query</b></td><td><b>Count</b></td><td><b> Average results</b></td><td><b>Last queried</b></td></tr>";
			        $result=mysql_query("select query, count(*) as c, date_format(max(time), '%Y-%m-%d %H:%i:%s'), avg(results)  from ".$mysql_table_prefix."query_log group by query order by c desc" );
				echo mysql_error();
				while ($row=mysql_fetch_row($result)) {
					if ($class =="white" ) 
						$class = "grey" ;
					else 
						$class = "white" ;

					$word = $row[0];
					$times = $row[1];
					$date = $row[2];
					$avg = number_format($row[3], 1);
					print "<tr class=\"$class\"><td align=\"left\">".htmlentities($word)."</td><td align=\"center\"> ".$times."</td><td align=\"center\"> ".$avg."</td><td align=\"center\"> ".$date."</td></tr>";
		 		}			
				print "</table></td></tr></table></div>";
			}

Delete all the above and replace it with

			if ($type=='top_searches') {
				$class = "grey";
                                $i = 0;
                                @unlink ("most_pop.txt" );                
				print "<br/><div align=\"center\"><table cellspacing =\"0\" cellpadding=\"0\" class=\"darkgrey\"><tr><td><table cellpadding=\"3\" cellspacing = \"1\"><tr  class=\"grey\"><td><b>Query</b></td><td><b>Count</b></td><td><b> Average results</b></td><td><b>Last queried</b></td></tr>";
                                $result=mysql_query("select query, count(*) as c, date_format(max(time), '%Y-%m-%d %H:%i:%s'), avg(results)  from ".$mysql_table_prefix."query_log group by query order by c desc" );
				echo mysql_error();
				while ($row=mysql_fetch_row($result)) {
					if ($class =="white" ) 
						$class = "grey";
					else 
						$class = "white";

					$word = $row[0];
					$times = $row[1];
					$date = $row[2];
					$avg = number_format($row[3], 1);
					print "<tr class=\"$class\"><td align=\"left\">".htmlentities($word)."</td><td align=\"center\"> ".$times."</td><td align=\"center\"> ".$avg."</td><td align=\"center\"> ".$date."</td></tr>";
                                        if ($i < 20) {
                                               $contents = "".htmlentities($word).";".$times.";".$avg.";".$date."\r\n";
                                               $fh = @fopen("most_pop.txt", "ab" );
                                               fwrite($fh, $contents);
                                               fclose($fh);
                                               $i++;
                                       }
                                }			
				print "</table></td></tr></table></div>";
			}

The new code will create the file
…/admin/most_pop.txt

Each time you select 'Most popular searches' in Admin backend, this file will be updated with the currently available values from database.
The file contains: query, count, average results and last queried, as you know it from the according table. The values are separated with colons.
Use this file to embed the values into your external page

Tec
Ant
Re: top 20 searches
December 19, 2014 07:39AM
Thank you.
Sorry, only registered users may post in this forum.

Click here to login