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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.