Jump to content

top 10 searches ???


scooby545

Recommended Posts

hi,

 

i have created a search bar for my site which records the users search data into a table.

 

the table name is `websmart_searches` and its structure is :

 

  `key` bigint(20) NOT NULL auto_increment,
  `search` varchar(255) NOT NULL,
  `user` varchar(255) NOT NULL,
  `blocked` varchar(255) NOT NULL default 'no',
  `date` varchar(255) NOT NULL,
  `IP` varchar(255) NOT NULL,
  `time` varchar(255) NOT NULL,

 

if the user searches for "phpfreaks" it will add a row like :

 

INSERT INTO `websmart_searches` VALUES(6, 'phpfreaks', 'me', 'no', '27th November 2009', '192.168.1.1', '13:52pm');

 

duplicate entries are allowed and needed.

 

what im trying to do is look at the data in the table and extract out the 10 most popular searches, based on an exact match ? does anyone know if this is possible using an sql query ?

 

thanks in advance

 

dave  :)

 

Link to comment
https://forums.phpfreaks.com/topic/183120-top-10-searches/
Share on other sites

More of a MySql problem.

 

But maybe some thing like this??

 

 


<?php
// Make a MySQL Connection

$query = "SELECT search, search(search) FROM websmart_searches GROUP BY search 			ORDER BY null
LIMIT 10"; 

$result = mysql_query($query) or die(mysql_error());

// Print out result
while($row = mysql_fetch_array($result)){
echo $row['search']. " - $". $row['search(search)'];
echo "<br />";
}
?>

 

Here the link where i got that from: http://www.tizag.com/mysqlTutorial/mysqlgroupby.php

Link to comment
https://forums.phpfreaks.com/topic/183120-top-10-searches/#findComment-966446
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.